home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / iconed1a / iconedit.frm < prev    next >
Text File  |  1999-09-24  |  112KB  |  2,930 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form Editor 
  4.    Caption         =   "IconWorks Editor: 1 - [Untitled]"
  5.    ClientHeight    =   4665
  6.    ClientLeft      =   1290
  7.    ClientTop       =   1830
  8.    ClientWidth     =   6165
  9.    ClipControls    =   0   'False
  10.    BeginProperty Font 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H00FFFFFF&
  20.    Icon            =   "ICONEDIT.frx":0000
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form1"
  23.    LockControls    =   -1  'True
  24.    PaletteMode     =   1  'UseZOrder
  25.    ScaleHeight     =   311
  26.    ScaleMode       =   3  'Pixel
  27.    ScaleWidth      =   411
  28.    Begin VB.PictureBox Pic_ToolPalette 
  29.       AutoSize        =   -1  'True
  30.       BackColor       =   &H00808080&
  31.       BorderStyle     =   0  'None
  32.       DrawWidth       =   2
  33.       Height          =   3840
  34.       Left            =   0
  35.       Picture         =   "ICONEDIT.frx":030A
  36.       ScaleHeight     =   256
  37.       ScaleMode       =   3  'Pixel
  38.       ScaleWidth      =   32
  39.       TabIndex        =   0
  40.       TabStop         =   0   'False
  41.       Top             =   0
  42.       Visible         =   0   'False
  43.       Width           =   480
  44.    End
  45.    Begin VB.VScrollBar Scrl_Zoom 
  46.       Height          =   3870
  47.       HelpContextID   =   1903
  48.       LargeChange     =   32
  49.       Left            =   480
  50.       Max             =   258
  51.       Min             =   34
  52.       SmallChange     =   32
  53.       TabIndex        =   4
  54.       Tag             =   "9040"
  55.       Top             =   -15
  56.       Value           =   34
  57.       Visible         =   0   'False
  58.       Width           =   270
  59.    End
  60.    Begin VB.PictureBox Pic_Edit 
  61.       Appearance      =   0  'Flat
  62.       BackColor       =   &H000000FF&
  63.       ForeColor       =   &H80000008&
  64.       Height          =   3870
  65.       Left            =   735
  66.       ScaleHeight     =   256
  67.       ScaleMode       =   3  'Pixel
  68.       ScaleWidth      =   256
  69.       TabIndex        =   2
  70.       Tag             =   "9000"
  71.       Top             =   -30
  72.       Visible         =   0   'False
  73.       Width           =   3870
  74.       Begin VB.PictureBox Pic_Mask 
  75.          Appearance      =   0  'Flat
  76.          AutoRedraw      =   -1  'True
  77.          BackColor       =   &H00FFFFFF&
  78.          BorderStyle     =   0  'None
  79.          ForeColor       =   &H00000000&
  80.          Height          =   480
  81.          Left            =   1965
  82.          ScaleHeight     =   32
  83.          ScaleMode       =   3  'Pixel
  84.          ScaleWidth      =   32
  85.          TabIndex        =   6
  86.          TabStop         =   0   'False
  87.          Top             =   945
  88.          Visible         =   0   'False
  89.          Width           =   480
  90.       End
  91.       Begin VB.PictureBox Pic_Image 
  92.          Appearance      =   0  'Flat
  93.          AutoRedraw      =   -1  'True
  94.          BackColor       =   &H00000000&
  95.          BorderStyle     =   0  'None
  96.          ForeColor       =   &H00000000&
  97.          Height          =   480
  98.          Left            =   1380
  99.          ScaleHeight     =   32
  100.          ScaleMode       =   3  'Pixel
  101.          ScaleWidth      =   32
  102.          TabIndex        =   5
  103.          TabStop         =   0   'False
  104.          Top             =   945
  105.          Visible         =   0   'False
  106.          Width           =   480
  107.       End
  108.       Begin VB.PictureBox Pic_Grid 
  109.          Appearance      =   0  'Flat
  110.          AutoRedraw      =   -1  'True
  111.          BackColor       =   &H00FFFFFF&
  112.          BorderStyle     =   0  'None
  113.          ForeColor       =   &H00000000&
  114.          Height          =   480
  115.          Left            =   1380
  116.          ScaleHeight     =   32
  117.          ScaleMode       =   3  'Pixel
  118.          ScaleWidth      =   32
  119.          TabIndex        =   19
  120.          Top             =   1515
  121.          Visible         =   0   'False
  122.          Width           =   480
  123.       End
  124.       Begin VB.PictureBox Pic_Work 
  125.          Appearance      =   0  'Flat
  126.          AutoRedraw      =   -1  'True
  127.          AutoSize        =   -1  'True
  128.          BackColor       =   &H00000000&
  129.          BorderStyle     =   0  'None
  130.          FillStyle       =   0  'Solid
  131.          ForeColor       =   &H00000000&
  132.          Height          =   480
  133.          Left            =   1965
  134.          ScaleHeight     =   32
  135.          ScaleMode       =   3  'Pixel
  136.          ScaleWidth      =   32
  137.          TabIndex        =   14
  138.          TabStop         =   0   'False
  139.          Top             =   1515
  140.          Visible         =   0   'False
  141.          Width           =   480
  142.       End
  143.       Begin VB.PictureBox Pic_TempImage 
  144.          Appearance      =   0  'Flat
  145.          AutoRedraw      =   -1  'True
  146.          BackColor       =   &H00000000&
  147.          BorderStyle     =   0  'None
  148.          ForeColor       =   &H00000000&
  149.          Height          =   480
  150.          Left            =   1380
  151.          ScaleHeight     =   32
  152.          ScaleMode       =   3  'Pixel
  153.          ScaleWidth      =   32
  154.          TabIndex        =   15
  155.          Top             =   2085
  156.          Visible         =   0   'False
  157.          Width           =   480
  158.       End
  159.       Begin VB.PictureBox Pic_TempMask 
  160.          Appearance      =   0  'Flat
  161.          AutoRedraw      =   -1  'True
  162.          BackColor       =   &H00FFFFFF&
  163.          BorderStyle     =   0  'None
  164.          ForeColor       =   &H00000000&
  165.          Height          =   480
  166.          Left            =   1965
  167.          ScaleHeight     =   32
  168.          ScaleMode       =   3  'Pixel
  169.          ScaleWidth      =   32
  170.          TabIndex        =   16
  171.          Top             =   2085
  172.          Visible         =   0   'False
  173.          Width           =   480
  174.       End
  175.       Begin VB.PictureBox Pic_EditTemp 
  176.          Appearance      =   0  'Flat
  177.          AutoRedraw      =   -1  'True
  178.          BackColor       =   &H00FFFFFF&
  179.          ForeColor       =   &H00000000&
  180.          Height          =   480
  181.          Left            =   1680
  182.          ScaleHeight     =   30
  183.          ScaleMode       =   3  'Pixel
  184.          ScaleWidth      =   30
  185.          TabIndex        =   20
  186.          Top             =   2745
  187.          Visible         =   0   'False
  188.          Width           =   480
  189.       End
  190.    End
  191.    Begin VB.PictureBox Pic_StatusArea 
  192.       BackColor       =   &H00C0C0C0&
  193.       BeginProperty Font 
  194.          Name            =   "Courier"
  195.          Size            =   9.75
  196.          Charset         =   0
  197.          Weight          =   700
  198.          Underline       =   0   'False
  199.          Italic          =   0   'False
  200.          Strikethrough   =   0   'False
  201.       EndProperty
  202.       FontTransparent =   0   'False
  203.       ForeColor       =   &H00C0C0C0&
  204.       Height          =   4680
  205.       HelpContextID   =   1904
  206.       Left            =   4590
  207.       ScaleHeight     =   308
  208.       ScaleMode       =   3  'Pixel
  209.       ScaleWidth      =   102
  210.       TabIndex        =   7
  211.       TabStop         =   0   'False
  212.       Tag             =   "9010"
  213.       Top             =   -30
  214.       Visible         =   0   'False
  215.       Width           =   1590
  216.       Begin VB.PictureBox Pic_Icons 
  217.          Appearance      =   0  'Flat
  218.          AutoRedraw      =   -1  'True
  219.          BackColor       =   &H80000005&
  220.          BorderStyle     =   0  'None
  221.          DragIcon        =   "ICONEDIT.frx":138C
  222.          FillStyle       =   0  'Solid
  223.          ForeColor       =   &H80000008&
  224.          Height          =   480
  225.          Index           =   0
  226.          Left            =   210
  227.          Picture         =   "ICONEDIT.frx":1696
  228.          ScaleHeight     =   32
  229.          ScaleMode       =   3  'Pixel
  230.          ScaleWidth      =   32
  231.          TabIndex        =   8
  232.          TabStop         =   0   'False
  233.          Tag             =   "9130"
  234.          Top             =   180
  235.          Width           =   480
  236.       End
  237.       Begin VB.PictureBox Pic_Icons 
  238.          Appearance      =   0  'Flat
  239.          BackColor       =   &H80000005&
  240.          BorderStyle     =   0  'None
  241.          DragIcon        =   "ICONEDIT.frx":19A0
  242.          FillStyle       =   0  'Solid
  243.          ForeColor       =   &H80000008&
  244.          Height          =   480
  245.          Index           =   1
  246.          Left            =   885
  247.          Picture         =   "ICONEDIT.frx":1CAA
  248.          ScaleHeight     =   32
  249.          ScaleMode       =   3  'Pixel
  250.          ScaleWidth      =   32
  251.          TabIndex        =   9
  252.          TabStop         =   0   'False
  253.          Tag             =   "9130"
  254.          Top             =   180
  255.          Width           =   480
  256.       End
  257.       Begin VB.PictureBox Pic_Icons 
  258.          Appearance      =   0  'Flat
  259.          BackColor       =   &H80000005&
  260.          BorderStyle     =   0  'None
  261.          DragIcon        =   "ICONEDIT.frx":1FB4
  262.          FillStyle       =   0  'Solid
  263.          ForeColor       =   &H80000008&
  264.          Height          =   480
  265.          Index           =   2
  266.          Left            =   210
  267.          Picture         =   "ICONEDIT.frx":22BE
  268.          ScaleHeight     =   32
  269.          ScaleMode       =   3  'Pixel
  270.          ScaleWidth      =   32
  271.          TabIndex        =   10
  272.          TabStop         =   0   'False
  273.          Tag             =   "9130"
  274.          Top             =   840
  275.          Width           =   480
  276.       End
  277.       Begin VB.PictureBox Pic_Icons 
  278.          Appearance      =   0  'Flat
  279.          BackColor       =   &H80000005&
  280.          BorderStyle     =   0  'None
  281.          DragIcon        =   "ICONEDIT.frx":25C8
  282.          FillStyle       =   0  'Solid
  283.          ForeColor       =   &H80000008&
  284.          Height          =   480
  285.          Index           =   3
  286.          Left            =   885
  287.          Picture         =   "ICONEDIT.frx":28D2
  288.          ScaleHeight     =   32
  289.          ScaleMode       =   3  'Pixel
  290.          ScaleWidth      =   32
  291.          TabIndex        =   11
  292.          TabStop         =   0   'False
  293.          Tag             =   "9130"
  294.          Top             =   840
  295.          Width           =   480
  296.       End
  297.       Begin VB.PictureBox Pic_Icons 
  298.          Appearance      =   0  'Flat
  299.          BackColor       =   &H80000005&
  300.          BorderStyle     =   0  'None
  301.          DragIcon        =   "ICONEDIT.frx":2BDC
  302.          FillStyle       =   0  'Solid
  303.          ForeColor       =   &H80000008&
  304.          Height          =   480
  305.          Index           =   4
  306.          Left            =   210
  307.          Picture         =   "ICONEDIT.frx":2EE6
  308.          ScaleHeight     =   32
  309.          ScaleMode       =   3  'Pixel
  310.          ScaleWidth      =   32
  311.          TabIndex        =   12
  312.          TabStop         =   0   'False
  313.          Tag             =   "9130"
  314.          Top             =   1500
  315.          Width           =   480
  316.       End
  317.       Begin VB.PictureBox Pic_Icons 
  318.          Appearance      =   0  'Flat
  319.          BackColor       =   &H80000005&
  320.          BorderStyle     =   0  'None
  321.          DragIcon        =   "ICONEDIT.frx":31F0
  322.          FillStyle       =   0  'Solid
  323.          ForeColor       =   &H80000008&
  324.          Height          =   480
  325.          Index           =   5
  326.          Left            =   885
  327.          Picture         =   "ICONEDIT.frx":34FA
  328.          ScaleHeight     =   32
  329.          ScaleMode       =   3  'Pixel
  330.          ScaleWidth      =   32
  331.          TabIndex        =   13
  332.          TabStop         =   0   'False
  333.          Tag             =   "9130"
  334.          Top             =   1500
  335.          Width           =   480
  336.       End
  337.       Begin VB.PictureBox Pic_Undo 
  338.          Appearance      =   0  'Flat
  339.          BackColor       =   &H80000005&
  340.          BorderStyle     =   0  'None
  341.          DragIcon        =   "ICONEDIT.frx":3804
  342.          ForeColor       =   &H80000008&
  343.          Height          =   480
  344.          HelpContextID   =   1902
  345.          Left            =   1035
  346.          Picture         =   "ICONEDIT.frx":3B0E
  347.          ScaleHeight     =   32
  348.          ScaleMode       =   3  'Pixel
  349.          ScaleWidth      =   32
  350.          TabIndex        =   3
  351.          TabStop         =   0   'False
  352.          Tag             =   "9150"
  353.          Top             =   2505
  354.          Width           =   480
  355.       End
  356.       Begin VB.OptionButton Opt_Mouse 
  357.          BackColor       =   &H00C0C0C0&
  358.          Height          =   360
  359.          Index           =   0
  360.          Left            =   690
  361.          TabIndex        =   17
  362.          Tag             =   "9160"
  363.          Top             =   3600
  364.          Value           =   -1  'True
  365.          Width           =   195
  366.       End
  367.       Begin VB.OptionButton Opt_Mouse 
  368.          BackColor       =   &H00C0C0C0&
  369.          Height          =   360
  370.          HelpContextID   =   1901
  371.          Index           =   1
  372.          Left            =   690
  373.          TabIndex        =   1
  374.          Tag             =   "9160"
  375.          Top             =   4200
  376.          Width           =   195
  377.       End
  378.    End
  379.    Begin VB.PictureBox Pic_ColorPalette 
  380.       Height          =   810
  381.       HelpContextID   =   1905
  382.       Left            =   0
  383.       ScaleHeight     =   50
  384.       ScaleMode       =   3  'Pixel
  385.       ScaleWidth      =   303
  386.       TabIndex        =   18
  387.       TabStop         =   0   'False
  388.       Tag             =   "9030"
  389.       Top             =   3840
  390.       Visible         =   0   'False
  391.       Width           =   4605
  392.    End
  393.    Begin MSComDlg.CommonDialog CMDialog1 
  394.       Left            =   15
  395.       Top             =   4140
  396.       _ExtentX        =   847
  397.       _ExtentY        =   847
  398.       _Version        =   393216
  399.       CancelError     =   -1  'True
  400.    End
  401.    Begin VB.Menu Menu_File 
  402.       Caption         =   "&File"
  403.       HelpContextID   =   1100
  404.       Begin VB.Menu Menu_FileSelection 
  405.          Caption         =   "&New"
  406.          HelpContextID   =   1101
  407.          Index           =   0
  408.       End
  409.       Begin VB.Menu Menu_FileSelection 
  410.          Caption         =   "&Open..."
  411.          HelpContextID   =   1102
  412.          Index           =   1
  413.       End
  414.       Begin VB.Menu Menu_FileSelection 
  415.          Caption         =   "&Save"
  416.          HelpContextID   =   1103
  417.          Index           =   2
  418.          Shortcut        =   +{F12}
  419.       End
  420.       Begin VB.Menu Menu_FileSelection 
  421.          Caption         =   "Save &As..."
  422.          HelpContextID   =   1104
  423.          Index           =   3
  424.          Shortcut        =   {F12}
  425.       End
  426.       Begin VB.Menu Menu_FileSelection 
  427.          Caption         =   "-"
  428.          Index           =   4
  429.       End
  430.       Begin VB.Menu Menu_FileSelection 
  431.          Caption         =   "E&xit"
  432.          HelpContextID   =   1105
  433.          Index           =   5
  434.       End
  435.    End
  436.    Begin VB.Menu Menu_Edit 
  437.       Caption         =   "&Edit"
  438.       HelpContextID   =   1200
  439.       Begin VB.Menu Menu_EditSelection 
  440.          Caption         =   "&Undo"
  441.          HelpContextID   =   1201
  442.          Index           =   0
  443.          Shortcut        =   %{BKSP}
  444.       End
  445.       Begin VB.Menu Menu_EditSelection 
  446.          Caption         =   "-"
  447.          Index           =   1
  448.       End
  449.       Begin VB.Menu Menu_EditSelection 
  450.          Caption         =   "Cu&t"
  451.          HelpContextID   =   1202
  452.          Index           =   2
  453.          Shortcut        =   +{DEL}
  454.       End
  455.       Begin VB.Menu Menu_EditSelection 
  456.          Caption         =   "&Copy"
  457.          HelpContextID   =   1203
  458.          Index           =   3
  459.          Shortcut        =   ^{INSERT}
  460.       End
  461.       Begin VB.Menu Menu_EditSelection 
  462.          Caption         =   "&Paste"
  463.          HelpContextID   =   1204
  464.          Index           =   4
  465.          Shortcut        =   +{INSERT}
  466.       End
  467.       Begin VB.Menu Menu_EditSelection 
  468.          Caption         =   "Paste &Opaque"
  469.          HelpContextID   =   1205
  470.          Index           =   5
  471.          Shortcut        =   ^O
  472.       End
  473.       Begin VB.Menu Menu_EditSelection 
  474.          Caption         =   "&Delete"
  475.          HelpContextID   =   1206
  476.          Index           =   6
  477.          Shortcut        =   {DEL}
  478.       End
  479.       Begin VB.Menu Menu_EditSelection 
  480.          Caption         =   "&Select All"
  481.          HelpContextID   =   1207
  482.          Index           =   7
  483.          Shortcut        =   ^A
  484.       End
  485.       Begin VB.Menu Menu_EditSelection 
  486.          Caption         =   "-"
  487.          Index           =   8
  488.       End
  489.       Begin VB.Menu Menu_EditSelection 
  490.          Caption         =   "Flip &Horizontal"
  491.          HelpContextID   =   1208
  492.          Index           =   9
  493.          Shortcut        =   ^H
  494.       End
  495.       Begin VB.Menu Menu_EditSelection 
  496.          Caption         =   "Flip &Vertical"
  497.          HelpContextID   =   1209
  498.          Index           =   10
  499.          Shortcut        =   ^V
  500.       End
  501.       Begin VB.Menu Menu_EditSelection 
  502.          Caption         =   "-"
  503.          Index           =   11
  504.       End
  505.       Begin VB.Menu Menu_EditSelection 
  506.          Caption         =   "Rotate 90  &Right"
  507.          HelpContextID   =   1210
  508.          Index           =   12
  509.          Shortcut        =   ^R
  510.       End
  511.       Begin VB.Menu Menu_EditSelection 
  512.          Caption         =   "Rotate 90  &Left"
  513.          HelpContextID   =   1211
  514.          Index           =   13
  515.          Shortcut        =   ^L
  516.       End
  517.       Begin VB.Menu Menu_EditSelection 
  518.          Caption         =   "-"
  519.          Index           =   14
  520.       End
  521.       Begin VB.Menu Menu_EditSelection 
  522.          Caption         =   "&Invert"
  523.          HelpContextID   =   1212
  524.          Index           =   15
  525.          Shortcut        =   ^I
  526.       End
  527.    End
  528.    Begin VB.Menu Menu_View 
  529.       Caption         =   "&View"
  530.       HelpContextID   =   1300
  531.       Begin VB.Menu Menu_ViewSelection 
  532.          Caption         =   "&Status Area"
  533.          Checked         =   -1  'True
  534.          HelpContextID   =   1301
  535.          Index           =   0
  536.          Shortcut        =   ^S
  537.       End
  538.       Begin VB.Menu Menu_ViewSelection 
  539.          Caption         =   "&Tool Palette"
  540.          Checked         =   -1  'True
  541.          HelpContextID   =   1302
  542.          Index           =   1
  543.          Shortcut        =   ^T
  544.       End
  545.       Begin VB.Menu Menu_ViewSelection 
  546.          Caption         =   "&Color Palette"
  547.          Checked         =   -1  'True
  548.          HelpContextID   =   1303
  549.          Index           =   2
  550.          Shortcut        =   ^C
  551.       End
  552.       Begin VB.Menu Menu_ViewSelection 
  553.          Caption         =   "&Zooming Scroll bar"
  554.          Checked         =   -1  'True
  555.          HelpContextID   =   1304
  556.          Index           =   3
  557.          Shortcut        =   ^Z
  558.       End
  559.       Begin VB.Menu Menu_ViewSelection 
  560.          Caption         =   "Show &All"
  561.          HelpContextID   =   1305
  562.          Index           =   4
  563.       End
  564.       Begin VB.Menu Menu_ViewSelection 
  565.          Caption         =   "-"
  566.          Index           =   5
  567.       End
  568.       Begin VB.Menu Menu_ViewSelection 
  569.          Caption         =   "&Grid"
  570.          HelpContextID   =   1306
  571.          Index           =   6
  572.          Shortcut        =   ^G
  573.       End
  574.       Begin VB.Menu Menu_ViewSelection 
  575.          Caption         =   "&Line Grid"
  576.          HelpContextID   =   1307
  577.          Index           =   7
  578.       End
  579.       Begin VB.Menu Menu_ViewSelection 
  580.          Caption         =   "&Dotted Grid"
  581.          HelpContextID   =   1308
  582.          Index           =   8
  583.       End
  584.       Begin VB.Menu Menu_ViewSelection 
  585.          Caption         =   "-"
  586.          Index           =   9
  587.       End
  588.       Begin VB.Menu Menu_ViewSelection 
  589.          Caption         =   "Zoom &In"
  590.          HelpContextID   =   1309
  591.          Index           =   10
  592.          Shortcut        =   ^{F11}
  593.       End
  594.       Begin VB.Menu Menu_ViewSelection 
  595.          Caption         =   "Zoom &Out"
  596.          HelpContextID   =   1310
  597.          Index           =   11
  598.          Shortcut        =   ^{F12}
  599.       End
  600.       Begin VB.Menu Menu_ViewSelection 
  601.          Caption         =   "-"
  602.          Index           =   12
  603.       End
  604.       Begin VB.Menu Menu_ViewSelection 
  605.          Caption         =   "&Focus to Editor on Drag&&Drop"
  606.          Checked         =   -1  'True
  607.          HelpContextID   =   1311
  608.          Index           =   13
  609.       End
  610.       Begin VB.Menu Menu_ViewSelection 
  611.          Caption         =   "Display &Border on selected Icon"
  612.          Checked         =   -1  'True
  613.          HelpContextID   =   1312
  614.          Index           =   14
  615.       End
  616.       Begin VB.Menu Menu_ViewSelection 
  617.          Caption         =   "&Pop-up Tools menu on Form Click"
  618.          Checked         =   -1  'True
  619.          HelpContextID   =   1313
  620.          Index           =   15
  621.       End
  622.    End
  623.    Begin VB.Menu Menu_Tools 
  624.       Caption         =   "&Tools"
  625.       HelpContextID   =   1400
  626.       Begin VB.Menu Menu_ToolsSelection 
  627.          Caption         =   "&Select"
  628.          HelpContextID   =   1401
  629.          Index           =   0
  630.       End
  631.       Begin VB.Menu Menu_ToolsSelection 
  632.          Caption         =   "&Paint"
  633.          HelpContextID   =   1402
  634.          Index           =   1
  635.       End
  636.       Begin VB.Menu Menu_ToolsSelection 
  637.          Caption         =   "&Fill"
  638.          HelpContextID   =   1403
  639.          Index           =   2
  640.       End
  641.       Begin VB.Menu Menu_ToolsSelection 
  642.          Caption         =   "&Line"
  643.          HelpContextID   =   1404
  644.          Index           =   3
  645.       End
  646.       Begin VB.Menu Menu_ToolsSelection 
  647.          Caption         =   "&Square"
  648.          HelpContextID   =   1405
  649.          Index           =   4
  650.       End
  651.       Begin VB.Menu Menu_ToolsSelection 
  652.          Caption         =   "Filled S&quare"
  653.          HelpContextID   =   1406
  654.          Index           =   5
  655.       End
  656.       Begin VB.Menu Menu_ToolsSelection 
  657.          Caption         =   "&Circle"
  658.          HelpContextID   =   1407
  659.          Index           =   6
  660.       End
  661.       Begin VB.Menu Menu_ToolsSelection 
  662.          Caption         =   "Filled C&ircle"
  663.          HelpContextID   =   1408
  664.          Index           =   7
  665.       End
  666.    End
  667.    Begin VB.Menu Menu_Icons 
  668.       Caption         =   "&Icons"
  669.       HelpContextID   =   1500
  670.       Begin VB.Menu Menu_IconsSelection 
  671.          Caption         =   "&1 - [Untitled]"
  672.          Index           =   0
  673.       End
  674.       Begin VB.Menu Menu_IconsSelection 
  675.          Caption         =   "&2 - [Untitled]"
  676.          Index           =   1
  677.       End
  678.       Begin VB.Menu Menu_IconsSelection 
  679.          Caption         =   "&3 - [Untitled]"
  680.          Index           =   2
  681.       End
  682.       Begin VB.Menu Menu_IconsSelection 
  683.          Caption         =   "&4 - [Untitled]"
  684.          Index           =   3
  685.       End
  686.       Begin VB.Menu Menu_IconsSelection 
  687.          Caption         =   "&5 - [Untitled]"
  688.          Index           =   4
  689.       End
  690.       Begin VB.Menu Menu_IconsSelection 
  691.          Caption         =   "&6 - [Untitled]"
  692.          Index           =   5
  693.       End
  694.    End
  695.    Begin VB.Menu Menu_Color 
  696.       Caption         =   "&Color"
  697.       HelpContextID   =   1600
  698.       Begin VB.Menu Menu_ColorSelection 
  699.          Caption         =   "&Colors..."
  700.          HelpContextID   =   1601
  701.          Index           =   0
  702.       End
  703.       Begin VB.Menu Menu_ColorSelection 
  704.          Caption         =   "&Default Color Palette"
  705.          Checked         =   -1  'True
  706.          HelpContextID   =   1602
  707.          Index           =   1
  708.       End
  709.       Begin VB.Menu Menu_ColorSelection 
  710.          Caption         =   "S&olid Colors Only"
  711.          HelpContextID   =   1603
  712.          Index           =   2
  713.       End
  714.       Begin VB.Menu Menu_ColorSelection 
  715.          Caption         =   "I&NI File Color Palette"
  716.          HelpContextID   =   1604
  717.          Index           =   3
  718.       End
  719.       Begin VB.Menu Menu_ColorSelection 
  720.          Caption         =   "-"
  721.          Index           =   4
  722.       End
  723.       Begin VB.Menu Menu_ColorSelection 
  724.          Caption         =   "&Save Color Palette to INI file"
  725.          HelpContextID   =   1605
  726.          Index           =   5
  727.       End
  728.       Begin VB.Menu Menu_ColorSelection 
  729.          Caption         =   "-"
  730.          Index           =   6
  731.       End
  732.       Begin VB.Menu Menu_ColorSelection 
  733.          Caption         =   "&Left/Right Colors"
  734.          Checked         =   -1  'True
  735.          HelpContextID   =   1606
  736.          Index           =   7
  737.       End
  738.       Begin VB.Menu Menu_ColorSelection 
  739.          Caption         =   "Screen/&Inverse Colors"
  740.          HelpContextID   =   1607
  741.          Index           =   8
  742.       End
  743.    End
  744.    Begin VB.Menu Menu_Brush 
  745.       Caption         =   "&Brush"
  746.       HelpContextID   =   1700
  747.       Begin VB.Menu Menu_BrushSelection 
  748.          Caption         =   "&Small (1 x 1)"
  749.          Checked         =   -1  'True
  750.          HelpContextID   =   1701
  751.          Index           =   1
  752.       End
  753.       Begin VB.Menu Menu_BrushSelection 
  754.          Caption         =   "&Medium (3 x 3)"
  755.          HelpContextID   =   1702
  756.          Index           =   3
  757.       End
  758.       Begin VB.Menu Menu_BrushSelection 
  759.          Caption         =   "&Large (5 x 5)"
  760.          HelpContextID   =   1703
  761.          Index           =   5
  762.       End
  763.    End
  764.    Begin VB.Menu Menu_Help 
  765.       Caption         =   "&Help"
  766.       Begin VB.Menu Menu_HelpSelection 
  767.          Caption         =   "&Index"
  768.          Index           =   1
  769.       End
  770.       Begin VB.Menu Menu_HelpSelection 
  771.          Caption         =   "&Keyboard"
  772.          Index           =   2
  773.       End
  774.       Begin VB.Menu Menu_HelpSelection 
  775.          Caption         =   "&Commands"
  776.          Index           =   3
  777.       End
  778.       Begin VB.Menu Menu_HelpSelection 
  779.          Caption         =   "&Using Help"
  780.          Index           =   4
  781.       End
  782.       Begin VB.Menu Menu_HelpSelection 
  783.          Caption         =   "-"
  784.          Index           =   5
  785.       End
  786.       Begin VB.Menu Menu_HelpSelection 
  787.          Caption         =   "&About..."
  788.          Index           =   6
  789.       End
  790.    End
  791. End
  792. Attribute VB_Name = "Editor"
  793. Attribute VB_GlobalNameSpace = False
  794. Attribute VB_Creatable = False
  795. Attribute VB_PredeclaredId = True
  796. Attribute VB_Exposed = False
  797. DefInt A-G, I-Z
  798. #If Win32 Then
  799.     DefLng H
  800. #Else
  801.     DefInt H
  802. #End If
  803.  
  804. ' When the View.Grid option is selected or deselected, this routine
  805. ' performs the neccessary checking, unchecking of the Grid menu item
  806. ' and Enables or disables the Grid type menu items appropriately,
  807. ' and creates the Grid if selected.
  808. Private Sub Activate_Grid()
  809.     Menu_ViewSelection(MID_GRID).Checked = Not Menu_ViewSelection(MID_GRID).Checked
  810.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  811.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  812.     If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  813.     Magnify_Icon 0, 0, 31, 31
  814. End Sub
  815.  
  816. Private Sub Adjust_Color_Palette()
  817.     ' Determine if Editor is large enough for ColorPalette
  818.     If (ScaleHeight < (Pic_ColorPalette.Height + 34)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  819.         Menu_ViewSelection(MID_COLOR_PALETTE).Checked = False
  820.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = False
  821.     Else
  822.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = True
  823.         ' Check if the ColorPalette is selected to be displayed.
  824.         If Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  825.             NewTop = ScaleHeight - Pic_ColorPalette.Height
  826.             NewWidth = ScaleWidth
  827.             ' Check if the StatusArea is currently displayed, since the StatusArea
  828.             ' affects the width of the ColorPalette.
  829.             If Menu_ViewSelection(MID_STATUS_BAR).Checked Then NewWidth = NewWidth - Pic_StatusArea.Width + 1
  830.             ' Reposition and Resize the ColorPalette.
  831.             Pic_ColorPalette.Move Pic_ColorPalette.Left, NewTop, NewWidth
  832.         End If
  833.     End If
  834. End Sub
  835.  
  836. ' When the Editor is Resized, the the Zoom Scrollbar must be resized,
  837. ' repositioned.  This routine performs the neccessary repositioning
  838. ' for the Zoom Scrollbar.
  839. '
  840. Private Sub Adjust_ScrollBar()
  841.     If Menu_ViewSelection(MID_TOOL_PALETTE).Checked Then NewLeft = Pic_ToolPalette.Width Else NewLeft = -1
  842.     NewHeight = ScaleHeight + 2 + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height
  843.     NewMax = ScaleWidth - (NewLeft - Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width) + 3 + (Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width)
  844.     ' Set the new Max value to the smaller of the NewHeight and the NewMax value.
  845.     If NewMax > NewHeight Then NewMax = NewHeight
  846.     ' We must adjust the New Max value obtained above so it is a multiple of 32.
  847.     While (NewMax - 2) Mod 32
  848.         NewMax = NewMax - 1
  849.     Wend
  850.     Scrl_Zoom.Move NewLeft, Scrl_Zoom.Top, Scrl_Zoom.Width, NewHeight
  851.     Scrl_Zoom.Max = NewMax
  852.     ' Determine if current size of the Editing area is larger than the new maximum size.
  853.     If Pic_Edit.Height > Scrl_Zoom.Max Then
  854.         Scrl_Zoom.Value = Scrl_Zoom.Max
  855.     Else
  856.         Scrl_Zoom_Change
  857.     End If
  858. End Sub
  859.  
  860. ' When the Editor is Resized, the the StatusArea must be resized, and hidden if necessary
  861. Private Sub Adjust_Status_Bar()
  862.     ' Determine if Editor is large enough for StatusArea
  863.     If ((ScaleHeight < (Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT)) Or (ScaleWidth < 2 * Pic_StatusArea.Width)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  864.         Menu_ViewSelection(MID_STATUS_BAR).Checked = False
  865.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = False
  866.     Else
  867.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = True
  868.         If Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  869.             OldHeight = Pic_StatusArea.Height
  870.             Pic_StatusArea.Move ScaleWidth - Pic_StatusArea.Width + 1, Pic_StatusArea.Top, Pic_StatusArea.Width, ScaleHeight + 2
  871.             NewTop = Pic_StatusArea.ScaleHeight - 4.25 * Opt_Mouse(0).Height
  872.             Opt_Mouse(0).Top = NewTop + 1.25 * Opt_Mouse(0).Height
  873.             Opt_Mouse(1).Top = NewTop + 3 * Opt_Mouse(0).Height
  874.             Visibility = NewTop >= (Pic_Icons(5).Top + Pic_Icons(5).Height + 2 * HIGHLIGHT + 4)
  875.             Opt_Mouse(0).Visible = Visibility
  876.             Opt_Mouse(1).Visible = Visibility
  877.             ' Determine if there is room to display the Undo Icon
  878.             If Opt_Mouse(0).Visible Then
  879.                 Pic_Undo.Visible = NewTop >= (Pic_Undo.Top + Pic_Undo.Height)
  880.             Else
  881.                 Pic_Undo.Visible = (Pic_Undo.Top + Pic_Undo.Height) <= Pic_StatusArea.ScaleHeight
  882.             End If
  883.             ' We only want to force it to repaint if its size has changed
  884.             If OldHeight <> Pic_StatusArea.Height Then Pic_StatusArea.Refresh
  885.         End If
  886.     End If
  887.  
  888. End Sub
  889.  
  890. ' When the Editor is Resized, the the ToolPalette may need to be hidden.
  891. Private Sub Adjust_Tool_Palette()
  892.     If ((ScaleHeight < (Pic_ToolPalette.Height + Pic_ColorPalette.Height)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked) Or ((ScaleHeight < Pic_ToolPalette.Height) And (Not Menu_ViewSelection(MID_COLOR_PALETTE).Checked)) Then
  893.         Menu_ViewSelection(MID_TOOL_PALETTE).Checked = False
  894.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = False
  895.     Else
  896.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = True
  897.     End If
  898. End Sub
  899.  
  900. ' To make magnified pixels appear more like single pixels when working
  901. ' with the various tools, this routine is used to adjust the actual pixel
  902. ' clicked to the Center or to the Edge of the selected magnified pixel.
  903. Private Sub Adjust_X_and_Y(X As Single, Y As Single, NewX, NewY, Adjustment)
  904.     Select Case Adjustment
  905.         Case TO_CENTER
  906.             NewX = (X \ PixelSize) * PixelSize + (PixelSize \ 2)
  907.             NewY = (Y \ PixelSize) * PixelSize + (PixelSize \ 2)
  908.         Case TO_EDGE
  909.             Xpix = X \ PixelSize
  910.             Ypix = Y \ PixelSize
  911.             If (X Mod PixelSize) >= (PixelSize / 2) Then Xpix = Xpix + 1
  912.             If (Y Mod PixelSize) >= (PixelSize / 2) Then Ypix = Ypix + 1
  913.             NewX = Xpix * PixelSize
  914.             NewY = Ypix * PixelSize
  915.     End Select
  916. End Sub
  917.  
  918. ' This routine is called when ever the selection is to be comitted to the Icon.
  919. Private Sub Commit_Selection(ResetFlags)
  920.     ' Erase the Rectangle highlighting the selection
  921.     If Selecting Then Draw_Selection_Rectangle
  922.     Scale_Region True, X1, Y1, X2, Y2, True
  923.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  924.     w = X2 - X1
  925.     h = Y2 - Y1
  926.     If Opaque Then
  927.         ' An exact copy of Mask and Image of the Selection are copied
  928.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, h, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  929.         R = BitBlt(Pic_Mask.hDC, X1, Y1, w, h, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  930.     Else
  931.         ' Only the Foreground colors are copied.
  932.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, h, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  933.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, h, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCINVERT)
  934.         R = BitBlt(Pic_Mask.hDC, X1, Y1, w, h, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  935.     End If
  936.     If ResetFlags Then
  937.         Selecting = False
  938.         MovingSelection = False
  939.     End If
  940.     ' Replace the Icons current Mask and Image bitmaps with the new ones.
  941.     Update_Icon Pic_Icons(CurrentIcon)
  942. End Sub
  943.  
  944. ' This routine is called either in response to an Edit.Cut or Edit.Copy
  945. Private Sub Copy_Selection_To_ClipBoard(X1, Y1, X2, Y2)
  946.     Scale_Region True, X1, Y1, X2, Y2, True
  947.     Pic_Work.Picture = LoadPicture()
  948.     Pic_Work.Move Pic_Work.Left, Pic_Work.Top, X2 - X1, Y2 - Y1
  949.     R = BitBlt(Pic_Work.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Icons(CurrentIcon).hDC, X1, Y1, SRCCOPY)
  950.     Clipboard.Clear
  951.     Clipboard.SetData Pic_Work.Image
  952. End Sub
  953.  
  954. ' The Grid is drawn on a separate Picture control with a White BackGround and
  955. ' Black Foreground, and is only drawn once.  When a piece of the
  956. ' grid is to be redisplayed, the part of the Grid that corresponds
  957. ' to the area of the Icon that needs to be updated is BitBlt'd
  958. ' from the Picture of the Grid over the top of the Displayed Icon,
  959. ' Using the SCRAND raster operation.
  960. Private Sub Create_Grid()
  961.     Pic_Grid.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  962.     Pic_Grid.Cls
  963.     If Menu_ViewSelection(MID_LINE_GRID).Checked Then
  964.         For i = 1 To 31
  965.             Pic_Grid.Line (0, i * PixelSize)-(Pic_Grid.ScaleWidth, i * PixelSize)
  966.             Pic_Grid.Line (i * PixelSize, 0)-(i * PixelSize, Pic_Grid.ScaleHeight)
  967.         Next i
  968.     Else
  969.         For Y = 0 To 31
  970.             For X = 0 To 31
  971.                 Pic_Grid.PSet ((X * PixelSize) + (PixelSize \ 2), (Y * PixelSize) + (PixelSize \ 2))
  972.             Next X
  973.         Next Y
  974.     End If
  975. End Sub
  976.  
  977. ' This routine is called in response to an Edit.Cut, Copy, or
  978. ' Delete menu selection.
  979. Private Sub Cut_Copy_Or_Delete_Selection(Index)
  980.     If Index = MID_DELETE Then
  981.         Scale_Region True, X1, Y1, X2, Y2, True
  982.     Else
  983.         Copy_Selection_To_ClipBoard X1, Y1, X2, Y2
  984.     End If
  985.     If Index <> MID_COPY Then
  986.         Delete_Selection_From_Icon
  987.         Selecting = False
  988.         Magnify_Icon X1, Y1, X2, Y2
  989.     End If
  990. End Sub
  991.  
  992. ' This routine is called either in response to an Edit.Cut or Edit.Delete
  993. Private Sub Delete_Selection_From_Icon()
  994.     Scale_Region True, X1, Y1, X2, Y2, True
  995.     Pic_Image.Line (X1, Y1)-(X2 - 1, Y2 - 1), BLACK, BF
  996.     Pic_Mask.Line (X1, Y1)-(X2 - 1, Y2 - 1), WHITE, BF
  997.     Update_Icon Pic_Icons(CurrentIcon)
  998. End Sub
  999.  
  1000. ' This routine is called to display the mouse coordinates.  The
  1001. ' coordinates are that of the magnified pixels, not the screen
  1002. ' coordinates, thus, regardless of the magnification of the Icon,
  1003. ' the coordinates will all range from 0-31.
  1004. Private Sub Display_Mouse_Coordinates(Xpix, Ypix)
  1005.     If (Xpix >= 0) And (Xpix <= 31) Then
  1006.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * 0.25
  1007.         Pic_StatusArea.Print Space$(Abs(Xpix < 10)) + Format$(Xpix);
  1008.     End If
  1009.     If (Ypix >= 0) And (Ypix <= 31) Then
  1010.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * 0.75
  1011.         Pic_StatusArea.Print Space$(Abs(Ypix < 10)) + Format$(Ypix);
  1012.     End If
  1013. End Sub
  1014.  
  1015. ' The routine is called to display
  1016. ' the Line or Box for the above tools when requested.
  1017. Private Sub Draw_Line_Or_Box()
  1018.     If CurrentTool = TID_LINE Then
  1019.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region)
  1020.     Else
  1021.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region), , B
  1022.     End If
  1023. End Sub
  1024.  
  1025. ' Since Windows INItialization files only allow the writing string information,
  1026. ' the Color Palette color values are stored in 3 strings, 1 for each row of the
  1027. ' color palette.  This routine is called to extract these color values from
  1028. ' the strings and assign them to the Long Integer Color array.
  1029. Private Sub Extract_Colors_From_String(ColorString As String, FirstColor, RefreshPalette)
  1030.     N = 1
  1031.     For C = FirstColor To FirstColor + 15
  1032.         i = InStr(N, ColorString, " ")
  1033.         If i = 0 Then i = Len(ColorString) + 1
  1034.         Colors(C) = Val(Mid$(ColorString, N, i - N))
  1035.         N = i + 1
  1036.     Next C
  1037.     If RefreshPalette Then
  1038.         Display_Color_Palette Pic_ColorPalette
  1039.         If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  1040.     End If
  1041. End Sub
  1042.  
  1043. ' This routine performs a Surface Flood fill of the selected area
  1044. ' within the Icon when the Fill tool is in use.  The Mask color
  1045. ' of all pixels that are different is then compare to the Mask
  1046. ' color of the original starting Pixel.  If the Mask colors are the
  1047. ' same the Pixel should be changed, otherwise it is unchanged.
  1048. Private Sub Fill_Tool_MouseUp(X As Single, Y As Single, X2, Y2)
  1049. Dim MaskColor As Long, NewPixelColor As Long
  1050.     If (Abs(X) >= 0) And (Abs(X) <= Pic_Edit.ScaleWidth) And (Abs(Y) >= 0) And (Abs(Y) <= Pic_Edit.ScaleHeight) Then
  1051.         Screen.MousePointer = HOURGLASS
  1052.         Xpixel = X \ PixelSize
  1053.         Ypixel = Y \ PixelSize
  1054.         MaskColor = Pic_Mask.Point(Xpixel, Ypixel)
  1055.         Pic_Work.FillColor = Pic_Edit.ForeColor
  1056.         Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  1057.         R = ExtFloodFill(Pic_Work.hDC, Xpixel, Ypixel, Pic_Icons(CurrentIcon).Point(Xpixel, Ypixel), FLOODFILLSURFACE)
  1058.         For Ypix = 0 To 31
  1059.             For Xpix = 0 To 31
  1060.                 NewPixelColor = Pic_Work.Point(Xpix, Ypix)
  1061.                 If (Pic_Icons(CurrentIcon).Point(Xpix, Ypix) <> NewPixelColor) And (Pic_Mask.Point(Xpix, Ypix) = MaskColor) Then
  1062.                     '
  1063.                     ' Pixel was changed by the FloodFill and its Mask matched that of the
  1064.                     ' starting Pixel, so we make the change on the Icons Image and Mask
  1065.                     '
  1066.                     If Opt_Mouse(SCREEN_COLORS).Value Then NewPixelColor = Pic_Image.ForeColor
  1067.                     Pic_Image.PSet (Xpix, Ypix), NewPixelColor
  1068.                     Pic_Mask.PSet (Xpix, Ypix)
  1069.                 End If
  1070.             Next Xpix
  1071.         Next Ypix
  1072.         Screen.MousePointer = DEFAULT
  1073.         X2 = 31
  1074.         Y2 = 31
  1075.     End If
  1076. End Sub
  1077.  
  1078. ' This routine Flips (Mirrors) the current Selection either
  1079. ' Horizontally or Vertically.   The Windows API StretchBlt()
  1080. ' routine is used to perform the Flip operation.
  1081. Private Sub Flip_Selection(Index)
  1082.     w = X2SelectFrom - X1SelectFrom
  1083.     h = Y2SelectFrom - Y1SelectFrom
  1084.     If Index = MID_FLIP_HORIZONTAL Then
  1085.         DestX = X2SelectFrom - 1
  1086.         DestY = Y1SelectFrom
  1087.         DestWidth = -w
  1088.         DestHeight = h
  1089.     Else
  1090.         DestX = X1SelectFrom
  1091.         DestY = Y2SelectFrom - 1
  1092.         DestWidth = w
  1093.         DestHeight = -h
  1094.     End If
  1095.     R = StretchBlt(Pic_TempImage.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, w, h, SRCCOPY)
  1096.     R = StretchBlt(Pic_TempMask.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, w, h, SRCCOPY)
  1097.     R = StretchBlt(Pic_Work.hDC, DestX, DestY, DestWidth, DestHeight, Pic_Work.hDC, X1SelectFrom, Y1SelectFrom, w, h, SRCCOPY)
  1098.     Scale_Region True, X1, Y1, X2, Y2, False
  1099.     If Not MovingSelection Then Commit_Selection False
  1100.     Magnify_Icon X1, Y1, X2, Y2
  1101. End Sub
  1102.  
  1103.  
  1104.  
  1105. Private Sub Form_Load()
  1106.  
  1107.     ' Determine color mode and set Icons Image bitmap size accordingly
  1108.     ' This value, ImageSize, is used within the routines Update_Icon and
  1109.     ' Extract_Image_And_Mask within ICONWRKS.BAS
  1110.     '
  1111.     If GetDeviceCaps(hDC, BITSPIXEL) = 8 Then
  1112.         ImageSize = 1024 'bytes
  1113.     Else
  1114.         ImageSize = 512  'bytes
  1115.     End If
  1116.  
  1117.     ' Depending on the Video mode and video driver being used for Windows,
  1118.     ' the controls on a form might not be the same dimensions when loaded
  1119.     ' under differenct resolutions.  Since the Editor is based on a
  1120.     ' 32x32 pixel Icon, the Picture controls that are used to manipulate
  1121.     ' the icons must be set at runtime to 32x32.
  1122.     '
  1123.     ' Position and size Icon within StatusArea
  1124.     '
  1125.     Edge = (Pic_StatusArea.ScaleWidth - 64) \ 3
  1126.     For Y = 0 To 2
  1127.         For X = 0 To 1
  1128.             Pic_Icons(X + Y * 2).Move Edge + X * (32 + Edge), Edge + Y * (32 + Edge), 32, 32
  1129.         Next X
  1130.     Next Y
  1131.  
  1132.     Pic_Mask.Move 0, 0, 32, 32
  1133.     Pic_Image.Move 0, 0, 32, 32
  1134.     Pic_TempMask.Move 0, 0, 32, 32
  1135.     Pic_TempImage.Move 0, 0, 32, 32
  1136.     Pic_Work.Move 0, 0, 32, 32
  1137.     Pic_Grid.Move 0, 0, 32, 32
  1138.     Pic_ToolPalette.Move 0, 0, 32, 256
  1139.     Pic_Undo.Move Pic_StatusArea.ScaleWidth - 34, (Editor.Pic_Icons(5).Top + Editor.Pic_Icons(5).Height + 2.5 * HIGHLIGHT), 32, 32
  1140.     
  1141.     Get_INI_File_Settings
  1142.  
  1143.     ' Adjust size of Editor appropriately for the Video mode.
  1144.     '
  1145.     
  1146.     If Screen.Height = EGA_HEIGHT Then
  1147.         '
  1148.         ' EGA mode
  1149.         '
  1150.         
  1151.         NewWidth = Width
  1152.         NewHeight = Screen.Height
  1153.         NewTop = 0
  1154.     Else
  1155.         ' VGA or Better
  1156.         '
  1157.         NewWidth = Screen.Width * 0.75
  1158.         NewHeight = Screen.Height * 0.75
  1159.         NewTop = (Screen.Height - NewHeight) \ 2
  1160.     End If
  1161.     Move (Screen.Width - NewWidth) \ 2, NewTop, NewWidth, NewHeight
  1162.  
  1163.     ' Icon is initially displayed at full maginification
  1164.     '
  1165.     Scrl_Zoom.Value = Scrl_Zoom.Max
  1166.  
  1167.     ' Create Monochrome Hdc and Bitmap to be used when replace the
  1168.     ' Icons Monochrome Mask.
  1169.     '
  1170.     hDCMono = CreateCompatibleDC(hDC)
  1171.     hBMMono = CreateCompatibleBitmap(hDCMono, 32, 32)
  1172.     hBMOldMono = SelectObject(hDCMono, hBMMono)
  1173.  
  1174.     ' The BackColor of the Editing area picture control, Pic_Edit,
  1175.     ' is set to Red at design time just so the picture controls contained
  1176.     ' within it are visible at design time.
  1177.     '
  1178.     Pic_Edit.BackColor = WHITE
  1179.  
  1180.     ' Select initial tool and brushsize
  1181.     '
  1182.     CurrentTool = TID_PAINT
  1183.     BrushSize = 1
  1184.   
  1185.     ' Initialize Default Mouse Colors
  1186.     '
  1187.     MouseColors(0) = BLACK  'Left
  1188.     MouseColors(1) = RED    'Right
  1189.     MouseColors(2) = WHITE  'Screen
  1190.     MouseColors(3) = BLACK  'Inverse
  1191.  
  1192.     ' Add Accelerators that are not available from the Menu Design window
  1193.     ' to the appropriate menu items.
  1194.     '
  1195.     Menu_FileSelection(MID_EXIT).Caption = "E&xit" + A_TAB + "Alt+F4"
  1196.     'Menu_EditSelection(MID_UNDO).Caption = "&Undo" + A_TAB + "Alt+Bksp"
  1197.     'Menu_EditSelection(MID_CUT).Caption = "Cu&t" + A_TAB + "Shift+Del"
  1198.     'Menu_EditSelection(MID_COPY).Caption = "&Copy" + A_TAB + "Ctrl+Ins"
  1199.     'Menu_EditSelection(MID_PASTE).Caption = "&Paste" + A_TAB + "Shift+Ins"
  1200.     'Menu_EditSelection(MID_PASTE_OPAQUE).Caption = "Paste &Opaque" + A_TAB + "Ctrl+Shift+Ins"
  1201.     'Menu_EditSelection(MID_DELETE).Caption = "&Delete" + A_TAB + "Del"
  1202.  
  1203.     ' Initialize all 6 Icons filename to UNTITLED, so a File.Save opertion
  1204.     ' will react just like a File.Save As, the first time.
  1205.     '
  1206.     For i = 0 To 5
  1207.       ICONINFO(i).FileName = UNTITLED
  1208.     Next i
  1209.     
  1210.     EditorLoaded = True
  1211.  
  1212. End Sub
  1213.  
  1214. ' Just for an added convience when selecting tools, Clicking anywhere
  1215. ' on the Editor that is not covered by another control, will display
  1216. ' the Tools menu as a pupup menu at that location.
  1217. '
  1218. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1219.  
  1220.     ' Menu is displayed on if the left button is used.
  1221.     '
  1222.     If (Button = RIGHT_BUTTON) And Menu_ViewSelection(MID_POPUP_MENU).Checked Then
  1223.         '
  1224.         ' The X and Y coordintes passed to the TrackPopupMenu() API routine
  1225.         ' are Screen coordinates in pixels, not Form coordinates, so, the
  1226.         ' X and Y coordinates of the Mouse must be adjusted, taking into
  1227.         ' account the position of the form.  And for a little more added
  1228.         ' convience, another adjustment is made so when the menu pops up,
  1229.         ' the mouse poiner is directly over the currently selected tool.
  1230.         '
  1231.         InPixels = ScaleWidth
  1232.         ScaleMode = TWIPS
  1233.         TwipsToPixels = ScaleWidth \ InPixels
  1234.         Borders = (Width - ScaleWidth)
  1235.         TitleBarAndMenu = (Height - ScaleHeight - Borders)
  1236.         IX = X + (Left \ TwipsToPixels)
  1237.         IY = Y + (Top + TitleBarAndMenu - CurrentTool * (TitleBarAndMenu \ 2)) \ TwipsToPixels
  1238.         ScaleMode = PIXELS
  1239.         Menu_ToolsSelection(CurrentTool).Checked = True
  1240.         R = TrackPopupMenu(GetSubMenu(GetMenu(hWnd), 3), 0, IX, IY, 0, hWnd, 0)
  1241.     End If
  1242.  
  1243. End Sub
  1244.  
  1245. ' Resizing of the Editor can, depending on the new size, force any
  1246. ' of the palettes to be hidden, so all major controls must be
  1247. ' resized, repositioned and possibly hidden in reponse to resizing
  1248. ' the Editor.
  1249. '
  1250. Private Sub Form_Resize()
  1251. Static LastWindowState
  1252.  
  1253.     ' Nothing is done if the Editor is minimized.
  1254.     '
  1255.     If WindowState = MINIMIZED Then
  1256.         '
  1257.         ' Hide ColorPalette since it should not be visible while the
  1258.         ' Editor is Minimized.
  1259.         '
  1260.         If ColorPaletteLoaded Then ColorPalette.Hide
  1261.  
  1262.     ElseIf ScaleHeight >= 34 Then
  1263.         '
  1264.         ' Hide the Editing area while resizing other controls
  1265.         ' to prevent uneccessary repaints.
  1266.         '
  1267.         Pic_Edit.Visible = False
  1268.  
  1269.         ' Adjust all major controls
  1270.         '
  1271.         Adjust_Status_Bar
  1272.         Adjust_Tool_Palette
  1273.         Adjust_Color_Palette
  1274.         Adjust_ScrollBar
  1275.     
  1276.         ' Hide or Show the major controls, based on their corresponding View
  1277.         ' menu item Checked value, which was set within the above *Adjust*
  1278.         ' routines.
  1279.         '
  1280.         Pic_ColorPalette.Visible = Menu_ViewSelection(MID_COLOR_PALETTE).Checked
  1281.         Pic_ToolPalette.Visible = Menu_ViewSelection(MID_TOOL_PALETTE).Checked
  1282.         Pic_StatusArea.Visible = Menu_ViewSelection(MID_STATUS_BAR).Checked
  1283.         Scrl_Zoom.Visible = Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked
  1284.         
  1285.         If (LastWindowState = MINIMIZED) And ColorPaletteLoaded Then ColorPalette.Show
  1286.  
  1287.     End If
  1288.  
  1289.     LastWindowState = WindowState
  1290.  
  1291. End Sub
  1292.  
  1293. ' Editor is being terminated
  1294. '
  1295. Private Sub Form_Unload(Cancel As Integer)
  1296.     
  1297.     ' Check fo any icons that have been modified since they
  1298.     ' were last saved.
  1299.     '
  1300.     Text = ""
  1301.     For i = 0 To 5
  1302.         If ICONINFO(i).Changed Then Text = Text + "Icon #" + Right$(Menu_IconsSelection(i).Caption, Len(Menu_IconsSelection(i).Caption) - 1) + CRLF
  1303.     Next i
  1304.     
  1305.     If Text <> "" Then
  1306.         '
  1307.         ' One or more icons were changed, so prompt user.
  1308.         '
  1309.         Text = Text + CRLF + "The icons listed have not been saved since their last modification.  Quit anyway?"
  1310.         Cancel = MsgBox(Text, 36, "ICONS HAVE CHANGED") = MBNO
  1311.     End If
  1312.  
  1313.     If Not Cancel Then
  1314.         '
  1315.         ' User wants to terminate Editor, so clean up.
  1316.         '
  1317.         EditorLoaded = False
  1318.         Unload ColorPalette
  1319.         SelectObject hBMMono, hBMOldMono
  1320.         DeleteObject hBMMono
  1321.         DeleteDC hDCMono
  1322.         WinHelp hWnd, dummy$, HELP_QUIT, 0
  1323.         Save_Settings_To_INI_File
  1324.         '
  1325.         ' If Editor was started up first (Null command line or anything other than
  1326.         ' "v" or "V") then we treat it as the main Form.  So, if the Viewer is loaded,
  1327.         ' we should as the user if the Viewer should also be terminated.
  1328.         '
  1329.         If (MainForm = ICONWORKS_EDITOR) And ViewerLoaded Then
  1330.             '
  1331.             ' Editor was started first and the Viewer is loaded so ask the user
  1332.             ' if the Viewer should also be terminated.
  1333.             '
  1334.             Text = "Terminate Viewer also?"
  1335.             If MsgBox(Text, 36, "IconWorks") = MBYES Then Unload Viewer
  1336.             MainForm = ICONWORKS_VIEWER
  1337.         End If
  1338.     End If
  1339.  
  1340. End Sub
  1341.  
  1342. ' In response to a MouseDown event in the Edit area, the first thing
  1343. ' that must be done is deterine what color to use when drawing the object.
  1344. Private Sub Get_Current_Colors(Button As Integer)
  1345. Dim Index As Integer
  1346.     ' Determine which of the 4 currently selected colors to use, and
  1347.     ' assign to the Edit area's foreground color.
  1348.     Index = Opt_Mouse(SCREEN_COLORS).Value * (-2) + Button - 1
  1349.     Pic_Edit.ForeColor = MouseColors(Index)
  1350.     ' If using the Paint tool, we must use the Neaest Solid color to the selected color.
  1351.     If CurrentTool = TID_PAINT Then Pic_Edit.ForeColor = GetNearestColor(hDC, Pic_Edit.ForeColor)
  1352.     If Opt_Mouse(MOUSE_COLORS).Value Then
  1353.         Pic_Image.ForeColor = Pic_Edit.ForeColor
  1354.     Else
  1355.         Pic_Image.ForeColor = (Button = RIGHT_BUTTON) And WHITE
  1356.     End If
  1357.     Pic_Mask.ForeColor = Opt_Mouse(SCREEN_COLORS).Value And WHITE
  1358.     Pic_Image.FillColor = Pic_Image.ForeColor
  1359.     Pic_Mask.FillColor = Pic_Mask.ForeColor
  1360.     Pic_Edit.FillColor = Pic_Edit.ForeColor
  1361. End Sub
  1362.  
  1363. ' This routine is called to read the color value strings from
  1364. ' the IconWrks.INI file, and then have The values extracted
  1365. Private Sub Get_INI_File_Colors()
  1366.     ColorString = Space$(144)
  1367.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "1", DEFAULT_COLORS_ROW1, ColorString, Len(ColorString), INI_FILENAME)
  1368.     Extract_Colors_From_String ColorString, 0, False
  1369.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "2", DEFAULT_COLORS_ROW2, ColorString, Len(ColorString), INI_FILENAME)
  1370.     Extract_Colors_From_String ColorString, 16, False
  1371.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "3", DEFAULT_COLORS_ROW3, ColorString, Len(ColorString), INI_FILENAME)
  1372.     Extract_Colors_From_String ColorString, 32, True
  1373. End Sub
  1374.  
  1375. ' This routine is called only once, which is at load time to obtain
  1376. ' all settings saved to the IconWrks.INI file.
  1377. Private Sub Get_INI_File_Settings()
  1378. Dim Index As Integer
  1379.     Menu_ViewSelection(MID_STATUS_BAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_STATUS_BAR, 1, INI_FILENAME)
  1380.     Menu_ViewSelection(MID_TOOL_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_TOOL_PALETTE, 1, INI_FILENAME)
  1381.     Menu_ViewSelection(MID_COLOR_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_COLOR_PALETTE, 1, INI_FILENAME)
  1382.     Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_ZOOM_SCROLLBAR, 1, INI_FILENAME)
  1383.     Menu_ViewSelection(MID_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_GRID, 0, INI_FILENAME)
  1384.     Menu_ViewSelection(MID_LINE_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_LINE_GRID, 1, INI_FILENAME)
  1385.     Menu_ViewSelection(MID_DOTTED_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DOTTED_GRID, 0, INI_FILENAME)
  1386.     Menu_ViewSelection(MID_FOCUS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_FOCUS, 1, INI_FILENAME)
  1387.     Menu_ViewSelection(MID_BORDER).Checked = -GetPrivateProfileInt(APP_NAME, KEY_BORDER, 1, INI_FILENAME)
  1388.     Menu_ViewSelection(MID_POPUP_MENU).Checked = -GetPrivateProfileInt(APP_NAME, KEY_POPUP, 1, INI_FILENAME)
  1389.     ' Get all Checked Color Menu item values
  1390.     Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DEFAULT, 1, INI_FILENAME)
  1391.     Menu_ColorSelection(MID_SOLID_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_SOLID, 0, INI_FILENAME)
  1392.     Menu_ColorSelection(MID_INI_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_INI, 0, INI_FILENAME)
  1393.     ' Enable or Disable the Grid type menu items based on the Check value
  1394.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1395.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1396.     ' Set initial color palette
  1397.     If Menu_ColorSelection(MID_DEFAULT_COLORS).Checked Then Index = MID_DEFAULT_COLORS
  1398.     If Menu_ColorSelection(MID_SOLID_COLORS).Checked Then Index = MID_SOLID_COLORS
  1399.     If Menu_ColorSelection(MID_INI_COLORS).Checked Then Index = MID_INI_COLORS
  1400.     Menu_ColorSelection_Click Index
  1401. End Sub
  1402.  
  1403. ' In response to an Edit.Invert menu item selection, this routine
  1404. ' Inverts the Colors of the selection region.  Using a DrawMode
  1405. ' of INVERSE, a filled box is drawn over the selected region, which
  1406. ' inverts the colors.
  1407. Private Sub Invert_Selection()
  1408.     Pic_TempImage.DrawMode = INVERSE
  1409.     Pic_Work.DrawMode = INVERSE
  1410.     ' Invert Selected Region.  Do not need to Invert Mask.
  1411.     Pic_TempImage.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1412.     Pic_Work.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1413.     Pic_TempImage.DrawMode = COPY_PEN
  1414.     Pic_Work.DrawMode = COPY_PEN
  1415.     If MovingSelection Then Draw_Selection_Rectangle Else Commit_Selection False
  1416.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  1417. End Sub
  1418.  
  1419. ' Once an object, Line, Square, Filled Square, Circle, or Filled Circle
  1420. ' has been size to what the user wants, this routine is called from the
  1421. ' MouseUp event for the Editing area (Pic_Edit) to display the actual
  1422. ' object.
  1423. Private Sub Line_To_Filled_Circle_MouseUp(X1, Y1, X2, Y2)
  1424.     Pic_Image.DrawWidth = BrushSize
  1425.     Pic_Mask.DrawWidth = BrushSize
  1426.     If CurrentTool = TID_FILLED_SQUARE Or CurrentTool = TID_FILLED_CIRCLE Then
  1427.         Pic_Image.FillStyle = SOLID
  1428.         Pic_Mask.FillStyle = SOLID
  1429.     End If
  1430.     ' Scale the dimensions of the object from the Editing area down
  1431.     ' to that of the Icon, 32x32.
  1432.     Scale_Region True, X1, Y1, X2, Y2, False
  1433.     Select Case CurrentTool
  1434.         Case TID_LINE
  1435.             Pic_Image.Line (X1, Y1)-(X2, Y2)
  1436.             '
  1437.             ' Draw end-point only if BrushSize is one Pixel
  1438.             If BrushSize = 1 Then Pic_Image.PSet (X2, Y2)
  1439.             Pic_Mask.Line (X1, Y1)-(X2, Y2)
  1440.             If BrushSize = 1 Then Pic_Mask.PSet (X2, Y2)
  1441.         Case TID_SQUARE, TID_FILLED_SQUARE
  1442.             Pic_Image.Line (X1, Y1)-(X2, Y2), , B
  1443.             Pic_Mask.Line (X1, Y1)-(X2, Y2), , B
  1444.         Case TID_CIRCLE, TID_FILLED_CIRCLE
  1445.             If Valid_Circle(X1, Y1, X2, Y2) Then
  1446.                 Pic_Image.Circle (XCenter, YCenter), Radius, , , , Aspect
  1447.                 Pic_Mask.Circle (XCenter, YCenter), Radius, , , , Aspect
  1448.                 Radius = 0
  1449.             End If
  1450.     End Select
  1451.     If X1 > X2 Then Swap_Values X1, X2
  1452.     If Y1 > Y2 Then Swap_Values Y1, Y2
  1453.     Pic_Image.DrawWidth = 1
  1454.     Pic_Mask.DrawWidth = 1
  1455.     Pic_Image.FillStyle = TRANSPARENT
  1456.     Pic_Mask.FillStyle = TRANSPARENT
  1457.  
  1458.     ' Only the area modified is redisplayed, which is the rectangle
  1459.     ' defined by the values of X1, Y1, X2, Y2.  If the Brushsize is
  1460.     ' greater than 1 pixel, then the actual area modified is slightly
  1461.     ' larger than the this rectangle, so the values X1, Y1, X2, Y2
  1462.     ' must be adjusted to include the thickness of the Brushsize so
  1463.     ' the entire area modified is redisplayed.
  1464.     '
  1465.     If (BrushSize > 1) And (CurrentTool >= TID_LINE) Then
  1466.         Adjustment = BrushSize \ 2
  1467.         X1 = X1 - Adjustment - 1
  1468.         Y1 = Y1 - Adjustment - 1
  1469.         X2 = X2 + Adjustment + 1
  1470.         Y2 = Y2 + Adjustment + 1
  1471.     End If
  1472.  
  1473. End Sub
  1474.  
  1475. ' For the Line, Square, Filled Square, Circle, and Filled Circle Tools,
  1476. ' an Inverted resizeable version of the object is displayed in response
  1477. ' to a MouseMove.  The object is anchored at the point set by the MouseDown
  1478. ' event within the Editing area.  This routine is called to erase the
  1479. ' old object and display the new object during a MouseMove event.
  1480. '
  1481. Private Sub Line_To_Filled_Circle_Tool_Move(Shift As Integer, X As Single, Y As Single)
  1482. Static LastCircleGood
  1483.  
  1484.     ' Erase Old object
  1485.     '
  1486.     Draw_Line_Or_Box
  1487.     If (CurrentTool >= TID_CIRCLE) And LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1488.     Adjust_X_and_Y X, Y, X2Region, Y2Region, TO_CENTER
  1489.  
  1490.     ' Holding the Shift key down forces a perfect Square or Circle.
  1491.     ' For a line, it forces either a Horizontal, Vertical or 45 degree
  1492.     ' line to be displayed.
  1493.     '
  1494.     If Shift And SHIFT_MASK Then Make_Region_Square
  1495.  
  1496.     If CurrentTool >= TID_CIRCLE Then
  1497.         '
  1498.         ' When sizing a circle, a rectangle with the circle displayed
  1499.         ' within the circle is drawn.  This is done to give a better
  1500.         ' feeling that the mouse is attached to the object when sizing.
  1501.         ' The rectanle is not drawn one the mouse is released.
  1502.         '
  1503.         LastCircleGood = Valid_Circle(X1Region, Y1Region, X2Region, Y2Region)
  1504.         If LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1505.     End If
  1506.  
  1507.     ' Draw New Object
  1508.     '
  1509.     Draw_Line_Or_Box
  1510.  
  1511. End Sub
  1512.  
  1513. ' To make creating a perfect Square, Circle, or a Diagonal, Vertical,
  1514. ' or Horizontal line, the routine is called whenever the Shift key
  1515. ' is depressed in conjuction to dragging the Mouse within the Editing
  1516. ' area.  This routine adjusts the actual mouse coordinates so that
  1517. ' the displayed object is Square, or in the case of a line, Diagonal,
  1518. ' Vertical, or Horizontal.
  1519. '
  1520. Private Sub Make_Region_Square()
  1521.     
  1522.     Xside = Abs(X2Region - X1Region)
  1523.     Yside = Abs(Y2Region - Y1Region)
  1524.     If Xside > Yside Then RectSide = Xside Else RectSide = Yside
  1525.     X2Region = X1Region + RectSide * Sgn(X2Region - X1Region)
  1526.     Y2Region = Y1Region + RectSide * Sgn(Y2Region - Y1Region)
  1527.  
  1528. End Sub
  1529.  
  1530. ' Changes size of brush to either 1x1, 3x3, or 5x5, and
  1531. ' Checks the corresponding Bush menu item
  1532. '
  1533. Private Sub Menu_BrushSelection_Click(Index As Integer)
  1534.   
  1535.     Menu_BrushSelection(BrushSize).Checked = False
  1536.     Menu_BrushSelection(Index).Checked = True
  1537.     BrushSize = Index
  1538.  
  1539. End Sub
  1540.  
  1541. ' Processes all Color Menu selections.
  1542. '
  1543. Private Sub Menu_ColorSelection_Click(Index As Integer)
  1544.     
  1545.     Select Case Index
  1546.  
  1547.         Case MID_COLORS
  1548.             '
  1549.             ' Invoke Custom ColorPalette form
  1550.             '
  1551.             ColorIndex = 0
  1552.             ColorPalette.Show
  1553.  
  1554.         Case MID_DEFAULT_COLORS
  1555.             '
  1556.             ' Default color palette is the same colors as the VB colorpalette
  1557.             '
  1558.             Extract_Colors_From_String DEFAULT_COLORS_ROW1, 0, False
  1559.             Extract_Colors_From_String DEFAULT_COLORS_ROW2, 16, False
  1560.             Extract_Colors_From_String DEFAULT_COLORS_ROW3, 32, True
  1561.         
  1562.         Case MID_SOLID_COLORS
  1563.             '
  1564.             ' Solid colors are the 16 colors returned from QBColors()
  1565.             '
  1566.             Menu_ColorSelection(MID_SOLID_COLORS).Checked = True
  1567.             Show_Solid_Colors_Only
  1568.  
  1569.         Case MID_INI_COLORS
  1570.             '
  1571.             ' If there are Colors saved to the INI file, they will
  1572.             ' be displayed, otherwise, the Default colors will be displayed
  1573.             '
  1574.             Menu_ColorSelection(MID_INI_COLORS).Checked = True
  1575.             Get_INI_File_Colors
  1576.  
  1577.         Case MID_SAVE_COLORS
  1578.             Save_Colors_To_INI_File
  1579.  
  1580.         Case MID_LEFT_RIGHT, MID_SCREEN_INVERSE
  1581.             '
  1582.             ' Same functionality as clicking either of the Mouse Option buttons
  1583.             '
  1584.             Opt_Mouse(Index - MID_LEFT_RIGHT).Value = True
  1585.     
  1586.     End Select
  1587.  
  1588.     ' If the selection was 1 of the 3 colorpalette selections, Check
  1589.     ' the current selection, and Uncheck the previous selection.
  1590.     '
  1591.     If (Index >= MID_DEFAULT_COLORS) And (Index <= MID_INI_COLORS) Then
  1592.         Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = (Index = MID_DEFAULT_COLORS)
  1593.         Menu_ColorSelection(MID_SOLID_COLORS).Checked = (Index = MID_SOLID_COLORS)
  1594.         Menu_ColorSelection(MID_INI_COLORS).Checked = (Index = MID_INI_COLORS)
  1595.     End If
  1596.  
  1597. End Sub
  1598.  
  1599. ' Prepares the Edit menus Sub menu items, by Enabling or Disabling
  1600. ' the menu items depending on whether there is a current selection
  1601. ' or if the current selection is being moved, and the current format
  1602. ' of the system ClipBoard.
  1603. '
  1604. Private Sub Menu_Edit_Click()
  1605.  
  1606.     Menu_EditSelection(MID_CUT).Enabled = Selecting And Not MovingSelection
  1607.     Menu_EditSelection(MID_COPY).Enabled = Selecting And Not MovingSelection
  1608.     Menu_EditSelection(MID_PASTE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1609.     Menu_EditSelection(MID_PASTE_OPAQUE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1610.     Menu_EditSelection(MID_DELETE).Enabled = Selecting And Not MovingSelection
  1611.     Menu_EditSelection(MID_FLIP_HORIZONTAL).Enabled = Selecting
  1612.     Menu_EditSelection(MID_FLIP_VERTICAL).Enabled = Selecting
  1613.     Menu_EditSelection(MID_ROTATE_LEFT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1614.     Menu_EditSelection(MID_ROTATE_RIGHT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1615.     Menu_EditSelection(MID_INVERT).Enabled = Selecting
  1616.  
  1617. End Sub
  1618.  
  1619. ' Processes all Edit Menu selections.
  1620. '
  1621. Private Sub Menu_EditSelection_Click(Index As Integer)
  1622.     Select Case Index
  1623.  
  1624.         Case MID_UNDO
  1625.             UnDo_Edits
  1626.  
  1627.         Case MID_CUT, MID_COPY, MID_DELETE
  1628.             Cut_Copy_Or_Delete_Selection Index
  1629.             
  1630.         Case MID_PASTE, MID_PASTE_OPAQUE
  1631.             Paste_ClipBoard_Contents Index
  1632.  
  1633.         Case MID_SELECT_ALL
  1634.             Select_Entire_Icon
  1635.  
  1636.         Case MID_FLIP_HORIZONTAL, MID_FLIP_VERTICAL
  1637.             Flip_Selection Index
  1638.  
  1639.         Case MID_ROTATE_RIGHT, MID_ROTATE_LEFT
  1640.             Rotate_Selection Index
  1641.  
  1642.         Case MID_INVERT
  1643.             Invert_Selection
  1644.  
  1645.     End Select
  1646.     
  1647. End Sub
  1648.  
  1649. ' Processes all File Menu selections.
  1650. '
  1651. Private Sub Menu_FileSelection_Click(Index As Integer)
  1652.  
  1653.     Select Case Index
  1654.  
  1655.         Case MID_NEW
  1656.             Prepare_For_New_Icon
  1657.       
  1658.         Case MID_OPEN
  1659.             Viewer.Show MODELESS
  1660.  
  1661.         Case MID_SAVE, MID_SAVE_AS
  1662.             Save_Icon Index
  1663.  
  1664.         Case MID_EXIT
  1665.             Unload Editor
  1666.  
  1667.     End Select
  1668.  
  1669. End Sub
  1670.  
  1671. ' Processes all Help Menu selections.
  1672. '
  1673. Private Sub Menu_HelpSelection_Click(Index As Integer)
  1674.  
  1675.     If Index = MID_ABOUT Then
  1676.         AboutBox.Show MODAL
  1677.     Else
  1678.         Get_Help Index
  1679.     End If
  1680.  
  1681. End Sub
  1682.  
  1683. ' Processes all Icons Menu selections.  Same as clicking
  1684. ' one of the Icons within the StatusArea.
  1685. '
  1686. Private Sub Menu_IconsSelection_Click(Index As Integer)
  1687.  
  1688.     Pic_Icons_MouseDown Index, LEFT_BUTTON, 0, 0, 0
  1689.   
  1690. End Sub
  1691.  
  1692. ' Prepares for the Tools sub menu to be shown, by Checking
  1693. ' the currently selected tool.
  1694. '
  1695. Private Sub Menu_Tools_Click()
  1696.  
  1697.     Menu_ToolsSelection(CurrentTool).Checked = True
  1698.  
  1699. End Sub
  1700.  
  1701. ' Processes all Tools Menu selections.  Same as clicking any
  1702. ' tool within the ToolPalette
  1703. '
  1704. Private Sub Menu_ToolsSelection_Click(Index As Integer)
  1705.  
  1706.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, Index * 32
  1707.     
  1708. End Sub
  1709.  
  1710. ' Processes all View Menu selections.
  1711. '
  1712. Private Sub Menu_ViewSelection_Click(Index As Integer)
  1713.  
  1714.     Select Case Index
  1715.  
  1716.         Case MID_STATUS_BAR, MID_TOOL_PALETTE, MID_COLOR_PALETTE, MID_ZOOM_SCROLLBAR, MID_FOCUS, MID_BORDER, MID_POPUP_MENU
  1717.             Menu_ViewSelection(Index).Checked = Not Menu_ViewSelection(Index).Checked
  1718.             If Index = MID_BORDER Then
  1719.                 HighLight_Current_Icon
  1720.             ElseIf Index < MID_FOCUS Then
  1721.                 '
  1722.                 ' Must process a From_Resize to make the Above selection
  1723.                 ' take affect since all hiding and showing of palettes is
  1724.                 ' done within the Form_Resize event.
  1725.                 '
  1726.                 Form_Resize
  1727.             End If
  1728.  
  1729.         Case MID_SHOW_ALL
  1730.             For i = 0 To 3
  1731.                 Menu_ViewSelection(i).Checked = True
  1732.             Next i
  1733.             Form_Resize
  1734.  
  1735.         Case MID_GRID
  1736.             Activate_Grid
  1737.  
  1738.         Case MID_LINE_GRID, MID_DOTTED_GRID
  1739.             Select_Grid_Type Index
  1740.  
  1741.         Case MID_ZOOM_IN
  1742.             Scrl_Zoom.Value = Scrl_Zoom.Value + 32
  1743.  
  1744.         Case MID_ZOOM_OUT
  1745.             Scrl_Zoom.Value = Scrl_Zoom.Value - 32
  1746.       
  1747.     End Select
  1748.   
  1749.     If ((Index = MID_STATUS_BAR) Or (Index = MID_SHOW_ALL)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then Display_Color_Palette Pic_ColorPalette
  1750.  
  1751. End Sub
  1752.  
  1753. ' One of the Mouse Button Options Buttons was selected, so update
  1754. ' the corresponding Color menu items Checked value.
  1755. '
  1756. Private Sub Opt_Mouse_Click(Index As Integer)
  1757.     
  1758.     Menu_ColorSelection(MID_LEFT_RIGHT).Checked = Not (-Index)
  1759.     Menu_ColorSelection(MID_SCREEN_INVERSE).Checked = -Index
  1760.  
  1761. End Sub
  1762.  
  1763. ' The paint tools is the only tool that paints directly to the
  1764. ' Editing area during the MouseMove event.  This routine draws
  1765. ' the pixels to the Icons Image and Mask, and to the Editing area,
  1766. ' so, there is no need to redisplay the modified area of the Icon
  1767. ' in response to a MouseUp event.  However, the StatusArea Icon
  1768. ' will not display the modificatioin until a MouseUp event.
  1769. '
  1770. Private Sub Paint_Tool_Move(Xpix, Ypix)
  1771.                 
  1772.     ' Adjust Mouse position so it is centered within the Pixel being
  1773.     ' drawn.
  1774.     '
  1775.     Adjustment = BrushSize \ 2
  1776.     X1 = Xpix - Adjustment
  1777.     Y1 = Ypix - Adjustment
  1778.     X2 = Xpix + Adjustment
  1779.     Y2 = Ypix + Adjustment
  1780.  
  1781.     ' Draw pixel on Icons Image and Mask
  1782.     '
  1783.     Pic_Image.Line (X1, Y1)-(X2, Y2), , BF
  1784.     Pic_Mask.Line (X1, Y1)-(X2, Y2), , BF
  1785.  
  1786.     ' Draw pixel on Editing area
  1787.     '
  1788.     X2 = X2 + 1
  1789.     Y2 = Y2 + 1
  1790.     Pic_Edit.Line (X1 * PixelSize, Y1 * PixelSize)-(X2 * PixelSize - 1, Y2 * PixelSize - 1), , BF
  1791.  
  1792.     ' Redisplay Grid in modified area if Grid is selected.
  1793.     '
  1794.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  1795.  
  1796. End Sub
  1797.  
  1798. ' In response to an Edit.Paste or Edit.Paste Opaque, this routine is called
  1799. ' to perform the acutal paste operation.  There are two forms of the Paste:
  1800. '
  1801. '   Paste Shift+Ins:  Creates a Mask from the bitmap in the clipboard
  1802. '                     based on the current Screen Color selected.  All
  1803. '                     Pixels in the Bitmap that match the Screen Color
  1804. '                     become transparent.
  1805. '
  1806. '   Paste Opaque Ctrl+Shift+Ins:  No mask is created from the bitmap and
  1807. '                     It is pasted as is with no Screen Color attributes.
  1808. '
  1809. Private Sub Paste_ClipBoard_Contents(Index)
  1810.             
  1811.     ' Get Bitmap from System Clipboard
  1812.     '
  1813.     Pic_Work.Picture = Clipboard.GetData(CF_BITMAP)
  1814.  
  1815.     ' Determine if Bitmap is too large to paste.  Must be 32x32 pixels or
  1816.     ' smaller.
  1817.     '
  1818.     If Pic_Work.Width <= 32 And Pic_Work.Height <= 32 Then
  1819.         '
  1820.         ' Change tool selection to SelectTool, which will allow us to
  1821.         ' move the Bitmap being pasted to anywhere within the Icon.
  1822.         '
  1823.         Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  1824.         
  1825.         Pic_TempImage.Picture = Pic_Work.Image
  1826.         Opaque = MID_PASTE - Index
  1827.  
  1828.         If Opaque Then
  1829.             ' An Opaque paste, so the Bitmap is pasted as is.  So we simply create
  1830.             ' a solid Black mask.
  1831.             '
  1832.             Pic_TempMask.Line (0, 0)-(Pic_TempMask.ScaleWidth, Pic_TempMask.ScaleHeight), BLACK, BF
  1833.         Else
  1834.             ' A normal paste, so a Mask must be created from the Bitmap being pasted,
  1835.             ' based on the currently selected Screen color.  The Mask is created, by
  1836.             ' BitBlt'ing the the 16-color bitmap to a mono Hdc.  All pixels in the color
  1837.             ' bitmap which are the screen color will be white in the monochrome bitmap,
  1838.             ' all others will be black.  That is why the Backcolor of the Picture control
  1839.             ' containing the bitmap is first set to the currently selected Screen color.
  1840.             ' This Monochrome bitmap is then BitBlt'd back to a 16-Color Picture control
  1841.             ' so we can easily manipulate it.
  1842.             '
  1843.             Pic_Work.BackColor = MouseColors(2)
  1844.             R = BitBlt(hDCMono, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCCOPY)
  1845.             R = BitBlt(Pic_TempMask.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, hDCMono, 0, 0, SRCCOPY)
  1846.                     
  1847.             ' Once the Mask is created, all the pixels in the Image bitmap which are of
  1848.             ' currently selected screen color must be changed to Black.  To do this we
  1849.             ' Logically AND the Mask created above with the Image bitmap.  This has the
  1850.             ' affect of turning all pixels which are not the screen color to Black, leaving
  1851.             ' screen color pixels unaffected.  We then XOR the image with this result, which
  1852.             ' gives us the desired result of all screen color pixels of the origianl
  1853.             ' bitmap going to Black, all other pixels are unaffected.
  1854.             '
  1855.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_TempMask.hDC, 0, 0, SRCAND)
  1856.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCINVERT)
  1857.         End If
  1858.  
  1859.         If (Pic_Work.Width = 32) And (Pic_Work.Height = 32) Then
  1860.             ' Bitmap Pasted is too large to allow it to be moved, so we
  1861.             ' commit the Bitmap to the Icon with out allowing it to be
  1862.             ' moved, and then redisplay the Icon.
  1863.             '
  1864.             Scale_Region False, 0, 0, 32, 32, False
  1865.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  1866.             Commit_Selection True
  1867.             Magnify_Icon 0, 0, 31, 31
  1868.         Else
  1869.             ' The Bitmap pasted can be moved, so go into Move mode by setting
  1870.             ' the appropriate flags.
  1871.             '
  1872.             Selecting = True
  1873.             
  1874.             MovingSelection = True
  1875.  
  1876.             ' Set the Selection Region to the size of the Bitmap pasted, in
  1877.             ' both the scale of the Icon and the Magnified Icon.
  1878.             '
  1879.             Scale_Region False, 0, 0, (Pic_Work.Width), (Pic_Work.Height), False
  1880.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  1881.             Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  1882.  
  1883.             ' Redisplay Icon.  Passing a values of 0,0,0,0 simply force the Magnify_Icon
  1884.             ' routine to magnify the pasted Bitmap over the top of the magnified Icon.
  1885.             '
  1886.             Magnify_Icon 0, 0, 0, 0
  1887.         End If
  1888.     Else
  1889.         ' Bitmap was too large to paste, so prompt the user.
  1890.         '
  1891.         Pic_Work.Picture = LoadPicture()
  1892.         MsgBox "ClipBoard image is too large:  " + Format$(Pic_Work.Width) + " x " + Format$(Pic_Work.Height) + CRLF + "Image not pasted", 16, "Error"
  1893.     End If
  1894.  
  1895. End Sub
  1896.  
  1897. ' ColorPalette operations are performed on the MouseUp event,
  1898. ' and DoubleClicking the ColorPalette invokes the Custom
  1899. ' color ColorPalette Form so a flag must be set to inform the
  1900. ' MouseUp event to invoke the Custom ColorPalette form.
  1901. '
  1902. Private Sub Pic_ColorPalette_DblClick()
  1903.  
  1904.     DoubleClicked = True
  1905.  
  1906. End Sub
  1907.  
  1908. ' Checks if Mouse Coordinates are within the ColorPalette, since the mouse
  1909. ' could have been dragged outside of the ColorPalette between the MouseDown
  1910. ' and MouseUp events, in which case the ColorPalette would still get the
  1911. ' MouseUp event with coordinates outside the actual ColorPalette which would
  1912. ' generate and error when accessing the Color Array.
  1913. '
  1914. Private Sub Pic_ColorPalette_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1915.     
  1916.     If (X >= 0) And (X <= 16) And (Y >= 0) And (Y <= 3) Then Update_Mouse_Colors Button, X, Y
  1917.  
  1918. End Sub
  1919.  
  1920. Private Sub Pic_ColorPalette_Paint()
  1921.  
  1922.     Display_Color_Palette Pic_ColorPalette
  1923.  
  1924. End Sub
  1925.  
  1926. ' If the Icon dropped is from the Viewer, it is loaded into the
  1927. ' currently selected Icon, otherwise nothing is done.
  1928. '
  1929. Private Sub Pic_Edit_DragDrop(Ctl As Control, X As Single, Y As Single)
  1930.  
  1931.     If Ctl.Parent.Tag <> Editor.Tag Then Load_An_Icon
  1932.  
  1933. End Sub
  1934.  
  1935. ' If the Icon being dragged is from the Viewer and it has just entered
  1936. ' or left the Edit area, invert the Edit area.
  1937. '
  1938. Private Sub Pic_Edit_DragOver(Ctl As Control, X As Single, Y As Single, State As Integer)
  1939.  
  1940.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then Invert_Control Pic_Edit
  1941.  
  1942. End Sub
  1943.  
  1944. ' A MouseDown event in the Editing area signals the beginning of a new
  1945. ' Tool operation if a tool operation is not already in progress.  All
  1946. ' preparation for the Tool operation is performed here, within the
  1947. ' MouseDown event.
  1948. '
  1949. Private Sub Pic_Edit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1950.  
  1951.     ' Propare for Tool operation only if there is not an operation already in
  1952.     ' progress, and only one mouse button is down, Left or Right.
  1953.     '
  1954.     If (ToolInProcess = 0) And ((Button = LEFT_BUTTON) Or (Button = RIGHT_BUTTON)) Then
  1955.         '
  1956.         ' Save Button value that started Tool Operation.
  1957.         '
  1958.         ToolInProcess = Button
  1959.  
  1960.         Get_Current_Colors Button
  1961.         Pic_Edit.DrawStyle = SOLID
  1962.  
  1963.         If CurrentTool = TID_PAINT Then
  1964.             '
  1965.             ' Begin a Paint tool operation.
  1966.             '
  1967.             Pic_Edit.DrawMode = COPY_PEN
  1968.             
  1969.             ' So a pixel is drawn in repsonse to just a Click within the editing
  1970.             ' area, the MouseMove event must be called since all the actual
  1971.             ' drawing to the Editing area for the Paint Tool is done within the
  1972.             ' MouseMove event.
  1973.             '
  1974.             Pic_Edit_MouseMove Button, 0, X, Y
  1975.  
  1976.         ElseIf CurrentTool <> TID_FILL Then
  1977.             '
  1978.             ' Prepare for all other tools other than Fill and Paint tools.
  1979.             '
  1980.             Pic_Edit.DrawMode = INVERSE
  1981.             If CurrentTool = TID_SELECT Then Adjustment = TO_EDGE Else Adjustment = TO_CENTER
  1982.  
  1983.             ' Determine if a Selection is in process, the Selection can be moved,
  1984.             ' and whether the MousePointer is within the current selection.
  1985.             '
  1986.             If Selecting And Moveable And ((X >= X1Region) And (X <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region)) Then
  1987.                 '
  1988.                 ' The selection is moveable and the MousePointer is within the
  1989.                 ' selection.  So prepare for a move.
  1990.                 '
  1991.                 Adjust_X_and_Y X, Y, XMoveSelection, YMoveSelection, Adjustment
  1992.                 If Button = RIGHT_BUTTON Then Opaque = True Else Opaque = False
  1993.  
  1994.                 If Not MovingSelection Then
  1995.                     '
  1996.                     ' The selection has not yet been moved from its original
  1997.                     ' position, so prepare to move selection.
  1998.                     '
  1999.                     ' If the Shift key is down, then the a copy of the Selection
  2000.                     ' will be moved, otherwise the selection will be move from
  2001.                     ' its current location so its previous location must be deleted.
  2002.                     '
  2003.                     If (Shift And SHIFT_MASK) = 0 Then Delete_Selection_From_Icon
  2004.                     Draw_Selection_Rectangle
  2005.                     MovingSelection = True
  2006.                     Draw_Selection_Rectangle
  2007.  
  2008.                 ElseIf (Shift And SHIFT_MASK) Then
  2009.                     '
  2010.                     ' The selection has already been moved from its original
  2011.                     ' location and is being moved again.  If the Shift key is
  2012.                     ' down, make a copy of the selection at its current location
  2013.                     ' and continue the move.
  2014.                     '
  2015.                     Commit_Selection False
  2016.                     Draw_Selection_Rectangle
  2017.                 End If
  2018.             Else
  2019.                 '
  2020.                 ' No selection is in progress, or a selection is in progress
  2021.                 ' but the MousePointer is not within the current selection,
  2022.                 ' or a tool other than the Select tool is in use.
  2023.                 '
  2024.                 ' If a Selection is in progress, commit the Selection at its
  2025.                 ' current location.
  2026.                 '
  2027.                 If Selecting Then Commit_Selection True
  2028.  
  2029.                 ' Prepare for new Tool operation
  2030.                 '
  2031.                 Opaque = True
  2032.                 Adjust_X_and_Y X, Y, X1Region, Y1Region, Adjustment
  2033.                 X2Region = X1Region
  2034.                 Y2Region = Y1Region
  2035.             End If
  2036.         End If
  2037.  
  2038.     End If
  2039.  
  2040. End Sub
  2041.  
  2042. ' For all tools except for the Paint tool and Fill tool, the MouseMove
  2043. ' event is used to size the object to be drawn.  The actual object is
  2044. ' drawn within the MouseUp event based on the coodinates obtained here
  2045. ' in the MouseMove event.  The Paint tool, however, does all of its
  2046. ' actual drawing to the Editing area within the MouseMove event.  The
  2047. ' Fill tool does nothing until the MouseUp event.
  2048. '
  2049. Private Sub Pic_Edit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2050.   
  2051.     ' Calculate pixel mouse is currently over.
  2052.     '
  2053.     Xpix = X \ PixelSize
  2054.     Ypix = Y \ PixelSize
  2055.  
  2056.     ' The Mouse coordinates are always displayed within the StatusArea
  2057.     '
  2058.     Display_Mouse_Coordinates Xpix, Ypix
  2059.  
  2060.     ' Depending on the Current tool, and in the case of the Select tool,
  2061.     ' the state of the Selection, the MousePointer may change.
  2062.     '
  2063.     Set_MousePointer X, Y
  2064.  
  2065.     ' We only want to process the MouseMove event if the Button causing
  2066.     ' the MouseMove event is the same that started the operation.
  2067.     ' The value of the Button that started the operation is stored in
  2068.     ' the global variable ToolInProcess which is set in the MouseDown event.
  2069.     '
  2070.     If (Button = ToolInProcess) And (ToolInProcess <> 0) Then
  2071.     
  2072.         Select Case CurrentTool
  2073.  
  2074.             Case TID_SELECT
  2075.                 Select_Tool_Move Shift, X, Y
  2076.  
  2077.             Case TID_PAINT
  2078.                 Paint_Tool_Move Xpix, Ypix
  2079.  
  2080.             Case TID_LINE To TID_FILLED_CIRCLE
  2081.                 Line_To_Filled_Circle_Tool_Move Shift, X, Y
  2082.  
  2083.         End Select
  2084.  
  2085.     End If
  2086.  
  2087. End Sub
  2088.  
  2089. ' For all tools except for the Paint tool, the actual object drawn
  2090. ' is not drawn until the Mouse Button is released, which is within
  2091. ' the the edit areas MouseUp event.
  2092. '
  2093. Private Sub Pic_Edit_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2094.  
  2095.     ' There is no operation that occurs with both mouse buttons down,
  2096.     ' so check to make sure that the MouseUp event is due to the release
  2097.     ' of the same button that started the drawing operation.  The global
  2098.     ' variable ToolInProcess holds the value of the Button.
  2099.     '
  2100.     If Button = ToolInProcess Then
  2101.  
  2102.         Pic_Edit.DrawMode = COPY_PEN
  2103.       
  2104.         Select Case CurrentTool
  2105.     
  2106.             Case TID_SELECT
  2107.                 Select_Tool_MouseUp X1, Y1, X2, Y2
  2108.     
  2109.             Case TID_FILL
  2110.                 Fill_Tool_MouseUp X, Y, X2, Y2
  2111.     
  2112.             Case TID_LINE To TID_FILLED_CIRCLE
  2113.                 Line_To_Filled_Circle_MouseUp X1, Y1, X2, Y2
  2114.     
  2115.         End Select
  2116.  
  2117.         ' The Icon needs to be updated to show the affect of the
  2118.         ' Tool operation for all tools except for the Select tool if
  2119.         ' just making a selection, since all that occurs is a Rectangle
  2120.         ' showing the selection is drawn.
  2121.         '
  2122.         If Not ((CurrentTool = TID_SELECT) And (Not MovingSelection)) Then
  2123.             Update_Icon Pic_Icons(CurrentIcon)
  2124.             '
  2125.             ' Redisplay the Icon for all tools except for the Paint tool.
  2126.             ' The paint tool draws directly on the Edit area within the
  2127.             ' MouseMove event.
  2128.             '
  2129.             If SeletedTool <> TID_PAINT Then Magnify_Icon X1, Y1, X2, Y2
  2130.         End If
  2131.     
  2132.         ToolInProcess = False
  2133.  
  2134.         ' Set enabled state of Edit Menu items.
  2135.         '
  2136.         Menu_Edit_Click
  2137.  
  2138.     End If
  2139.  
  2140. End Sub
  2141.  
  2142. Private Sub Pic_Edit_Paint()
  2143.  
  2144.     ' Repaint Edit area
  2145.     Magnify_Icon 0, 0, 31, 31
  2146.  
  2147. End Sub
  2148.  
  2149. ' If the Icon dropped is from the Viewer, it is loaded into the
  2150. ' StatusArea Icon on which is was dropped and that icon is made
  2151. ' the current Icon, otherwise nothing is done.
  2152. '
  2153. Private Sub Pic_Icons_DragDrop(Index As Integer, Ctl As Control, X As Single, Y As Single)
  2154.  
  2155.     If Ctl.Parent.Tag <> Editor.Tag Then
  2156.         CurrentIcon = Index
  2157.         Load_An_Icon
  2158.     End If
  2159.  
  2160. End Sub
  2161.  
  2162. ' If the Icon being dragged is from the Viewer and it has just entered
  2163. ' or left one of the StatusArea Icons, invert the StatusArea icon.
  2164. '
  2165. Private Sub Pic_Icons_DragOver(Index As Integer, Ctl As Control, X As Single, Y As Single, State As Integer)
  2166.  
  2167.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then
  2168.         Invert_Control Pic_Icons(Index)
  2169.         Pic_Icons(Index).Refresh
  2170.     End If
  2171.  
  2172. End Sub
  2173.  
  2174. ' Clicking on any of the icons within the StatusArea, makes that
  2175. ' Icon the current Icon.  If the the Icon is already the current
  2176. ' Icon, and selection currently in progress is canceled, and
  2177. ' the Icon can be dragged to test what it looks like begin dragged.
  2178. ' It cannot be dropped on anything.
  2179. '
  2180. Private Sub Pic_Icons_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  2181.  
  2182.     ' Determine if new Icon is being selected
  2183.     '
  2184.     If (Button = LEFT_BUTTON) And (Index <> CurrentIcon) Then
  2185.         '
  2186.         ' New Icon has been selected, so prepare for new Icon
  2187.         '
  2188.         Menu_IconsSelection(CurrentIcon).Checked = False
  2189.         Menu_IconsSelection(Index).Checked = True
  2190.         If Selecting Then Commit_Selection True
  2191.         CurrentIcon = Index
  2192.         Select_New_Icon
  2193.     ElseIf (Button = LEFT_BUTTON) And (Index = CurrentIcon) Then
  2194.         '
  2195.         ' The current Icon was selected.
  2196.         '
  2197.         If Selecting Then
  2198.             '
  2199.             ' A selection was in progress so cancel it.
  2200.             '
  2201.             Draw_Selection_Rectangle
  2202.             Selecting = False
  2203.             MovingSelection = False
  2204.             Scale_Region True, X1, Y1, X2, Y2, True
  2205.             Magnify_Icon X1, Y1, X2, Y2
  2206.         End If
  2207.         
  2208.         ' Set the DragIcon of the selected Icon, and begin dragging
  2209.         '
  2210.         Pic_Icons(Index).DragIcon = Pic_Icons(Index).Picture
  2211.         Pic_Icons(Index).Drag
  2212.     End If
  2213.  
  2214. End Sub
  2215.  
  2216. ' Although the StatusArea appears as though it contains many controls
  2217. ' it actually contains only 7 picture controls and 2 Option buttons.
  2218. ' The rest of the information displayed within the StatusArea is painted
  2219. ' directly onto the StatusArea.  This is done to limit the actual number
  2220. ' of controls on the Editor.  The more controls, the more System resources
  2221. ' it uses and the longer it takes to load.  It may be easier to display
  2222. ' certain data using controls, but in some cases, its benificial to not
  2223. ' use controls but display the information yourself.  The easiest controls
  2224. ' to eliminate are Labels since they usually just display text and do
  2225. ' not change throughout the life of the program, and the .Print method
  2226. ' can be used to display the text instead of a label.
  2227. '
  2228. Private Sub Pic_StatusArea_Paint()
  2229.  
  2230.     ' Calculate center of StatusArea
  2231.     '
  2232.     Middle = Pic_StatusArea.ScaleWidth \ 2
  2233.  
  2234.     ' Set font attributes for X & Y Mouse coodinate display
  2235.     '
  2236.     Pic_StatusArea.FontName = "MS Sans Serif"
  2237.     Pic_StatusArea.FontSize = 8.25
  2238.     Pic_StatusArea.ForeColor = BLACK
  2239.  
  2240.     ' Display X & Y mouse coordinate labels, "X=" and Y="
  2241.     '
  2242.     Pic_StatusArea.CurrentY = Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT + 1
  2243.     Pic_StatusArea.CurrentX = (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  2244.     Pic_StatusArea.Print "X=";
  2245.     Pic_StatusArea.CurrentX = Middle + (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  2246.     Pic_StatusArea.Print "Y=";
  2247.     
  2248.     ' If the Undo Icon is visible, display its label, "Undo to:"
  2249.     '
  2250.     If Pic_Undo.Visible Then
  2251.         Text = "Undo to:"
  2252.         Pic_StatusArea.CurrentX = (Pic_Undo.Left - Pic_StatusArea.TextWidth(Text)) \ 2
  2253.         Pic_StatusArea.CurrentY = Pic_Undo.Top + ((Pic_Undo.Height - Pic_StatusArea.TextHeight(Text)) \ 2)
  2254.         Pic_StatusArea.Print "Undo to:"
  2255.     End If
  2256.     
  2257.     ' If the Mouse Option buttons are visible, then display the the
  2258.     ' option button Color labels and the colors themselves.  The labels are
  2259.     ' all based on the positions of the two Option buttons, so it they
  2260.     ' are moved at design time, the labels will still be displayed
  2261.     ' correctly.
  2262.     '
  2263.     If Opt_Mouse(0).Visible Then
  2264.         '
  2265.         ' Display Mouse Butons header label within a White box with a Black
  2266.         ' outline.
  2267.         '
  2268.         Text = "Mouse Buttons"
  2269.         Y1 = Opt_Mouse(0).Top - 1.25 * Opt_Mouse(0).Height
  2270.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth, Y1 + Pic_StatusArea.TextHeight(Text)), WHITE, BF
  2271.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth - 1, Y1 + Pic_StatusArea.TextHeight(Text)), BLACK, B
  2272.         Pic_StatusArea.CurrentX = (Pic_StatusArea.ScaleWidth - Pic_StatusArea.TextWidth(Text)) \ 2
  2273.         Pic_StatusArea.CurrentY = Y1
  2274.         Pic_StatusArea.FontTransparent = True
  2275.         Pic_StatusArea.Print Text
  2276.         Pic_StatusArea.FontBold = False
  2277.  
  2278.         ' Display the Mouse Button color labels, centered on either
  2279.         ' side of the Option buttons.
  2280.         '
  2281.         For i = 0 To 3
  2282.             Select Case i
  2283.                 Case 0
  2284.                     Text = "Left"
  2285.                 Case 1
  2286.                     Text = "Right"
  2287.                     Shift = Middle
  2288.                 Case 2
  2289.                     Text = "Screen"
  2290.                     Shift = 0
  2291.                 Case 3
  2292.                     Text = "Inverse"
  2293.                     Shift = Middle
  2294.             End Select
  2295.             Pic_StatusArea.CurrentX = Shift + (Middle - Pic_StatusArea.TextWidth(Text)) \ 2
  2296.             Pic_StatusArea.CurrentY = Opt_Mouse(i \ 2).Top - Pic_StatusArea.TextHeight(Text) - 1
  2297.             Pic_StatusArea.Print Text
  2298.         Next i
  2299.  
  2300.         ' Display the 4 color squares showing currently selected colors
  2301.         ' These could be picture controls.
  2302.         '
  2303.         Display_Mouse_Colors
  2304.     End If
  2305.  
  2306.     ' Set StatusArea font attributes back to that of the Mouse coordinates.
  2307.     '
  2308.     Pic_StatusArea.ForeColor = RED
  2309.     Pic_StatusArea.FontName = "Courier"
  2310.     Pic_StatusArea.FontBold = True
  2311.     Pic_StatusArea.FontTransparent = False
  2312.  
  2313.     HighLight_Current_Icon
  2314.  
  2315. End Sub
  2316.  
  2317. ' Performs a "Select All" opertation, just as though the Edit.Select all
  2318. ' menu item was selected.
  2319. '
  2320. Private Sub Pic_ToolPalette_DblClick()
  2321.  
  2322.     If CurrentTool = TID_SELECT Then Menu_EditSelection_Click MID_SELECT_ALL
  2323.  
  2324. End Sub
  2325.  
  2326. ' Prepare for a new tool.  The actual Tool selection is done within
  2327. ' the MouseMove event.
  2328. '
  2329. Private Sub Pic_ToolPalette_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2330.     
  2331.     ' Commit and Selection currently being moved.
  2332.     '
  2333.     If Selecting Then Commit_Selection True
  2334.  
  2335.     ' Commit all edits to Undo Icon
  2336.     '
  2337.     Update_Icon Pic_Undo
  2338.  
  2339.     ' Remove Check from current tool in Tools menu
  2340.     '
  2341.     Menu_ToolsSelection(CurrentTool).Checked = False
  2342.  
  2343.     ' Since the actual selection is done within the MouseMove event, and
  2344.     ' a MouseMove event does not occur until the mouse is moved within
  2345.     ' the ToolPalette, we need to call the MouseMove event, to ensure
  2346.     ' the selected tool is in fact selected, since just clicking on
  2347.     ' the ToolPalette does not generate a MouseMove event.
  2348.     '
  2349.     Pic_ToolPalette_MouseMove Button, Shift, X, Y
  2350.  
  2351. End Sub
  2352.  
  2353. ' Moving the mouse within the ToolPalette after a MouseDown event, will select
  2354. ' the tool the mouse is currently over, so you can slide up and down the palette,
  2355. ' and the tool selection will follow the mouse.
  2356. '
  2357. Private Sub Pic_ToolPalette_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2358.     
  2359.     ' Calculate selected tool.  Each tool Icon is 32 pixels high, so this
  2360.     ' is done easily by Integer dividing the Y coordinate by 32.
  2361.     '
  2362.     NewTool = Y \ 32
  2363.  
  2364.     ' Check to make sure the Mouse is within the Y limits of the ToolPalette
  2365.     ' and not over the currently selected tool.
  2366.     '
  2367.     If (Button <> 0) And (NewTool >= TID_SELECT) And (NewTool <= TID_FILLED_CIRCLE) And (NewTool <> CurrentTool) Then
  2368.         '
  2369.         ' UnHighlight current tool
  2370.         '
  2371.         Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2372.  
  2373.         ' Hightlight new tool
  2374.         '
  2375.         Pic_ToolPalette.Line (0, NewTool * 32 + 1)-(31, NewTool * 32 + 31), , BF
  2376.  
  2377.         CurrentTool = NewTool
  2378.     End If
  2379.   
  2380. End Sub
  2381.  
  2382. Private Sub Pic_ToolPalette_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2383.     
  2384.     ' Set Enabled state of all Edit menu options.
  2385.     '
  2386.     Menu_Edit_Click
  2387.  
  2388. End Sub
  2389.  
  2390. ' The ToolPalette takes care of painting itself since it contains
  2391. ' a single bitmap displaying the Tools.  However, the currently
  2392. ' selected Tool needs to be Hightlighted during the Paint event.
  2393. '
  2394. Private Sub Pic_ToolPalette_Paint()
  2395.     
  2396.     ' Clear ToolPalette to background bitmap of Tools
  2397.     '
  2398.     Pic_ToolPalette.Cls
  2399.  
  2400.     ' HightLight current tool.  The Drawmode of the ToolPalette is
  2401.     ' set to INVERSE, so we simply draw a filled box over the current
  2402.     ' tool.  This inverts the tool.
  2403.     '
  2404.     Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2405.  
  2406. End Sub
  2407.  
  2408. ' Clicking the Undo Icon in the StatusArea is the same thing as
  2409. ' selecting the Edit.Undo menu item.
  2410. '
  2411. Private Sub Pic_Undo_Click()
  2412.  
  2413.     Menu_EditSelection_Click MID_UNDO
  2414.  
  2415. End Sub
  2416.  
  2417. ' In response to a File.New menu opertation, this routine is called,
  2418. ' to prepare creating a new Icon from scratch.
  2419. '
  2420. Private Sub Prepare_For_New_Icon()
  2421.     
  2422.     ' Determine if current Icon has changed since it was saved last and
  2423.     ' and prompt user if it has been changed and not saved.
  2424.     '
  2425.     If Ok_To_Discard_Changes() Then
  2426.         '
  2427.         ' It is ok to prepare for new Icon.
  2428.         
  2429.         ' Terminate any Selection in progress and simulate a Select all,
  2430.         ' then perform an Edit.Delete operation to clear the Icon.
  2431.         '
  2432.         Selecting = False
  2433.         MovingSelection = False
  2434.         Scale_Region False, 0, 0, 32, 32, False
  2435.         Menu_EditSelection_Click MID_DELETE
  2436.  
  2437.         ' Intialize the IconInfo record to default values
  2438.         '
  2439.         ICONINFO(CurrentIcon).FileName = UNTITLED
  2440.         ICONINFO(CurrentIcon).Changed = False
  2441.  
  2442.         ' Reset both the Icon menu and the Editors Titlebar
  2443.         '
  2444.         Menu_IconsSelection(CurrentIcon).Caption = "&" + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2445.  
  2446.         Caption = "IconWorks Editor: " + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2447.     End If
  2448.  
  2449. End Sub
  2450.  
  2451. ' Once a Selection has been made, or an Edit.Select All or Edit.Paste
  2452. ' operation has been made, this routine is called to prepare for a
  2453. ' potential movement of the Selection.  A copy of the actual Icons
  2454. ' Mask and Image are made, and this is the Source from which the
  2455. ' Selection is display whenever the Selection is in fact moved.
  2456. '
  2457. Private Sub Prepare_For_Possible_Move()
  2458.               
  2459.     Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  2460.     Pic_TempImage.Picture = Pic_Image.Image
  2461.     Pic_TempMask.Picture = Pic_Mask.Image
  2462.  
  2463. End Sub
  2464.  
  2465. ' When a selection has been made and the selection is Square, it may
  2466. ' be rotated Left or Right by 90 degrees.  Cannot Rotate a selection
  2467. ' that is being moved.  This routine performs the rotation in repsonse
  2468. ' to an Edit.Rotate Left/Right menu operation.
  2469. '
  2470. Private Sub Rotate_Selection(Index)
  2471.     
  2472.     ' Rotation is not instant, so set Cursor to HourGlass
  2473.     '
  2474.     Screen.MousePointer = HOURGLASS
  2475.  
  2476.     ' Caculate size of Region
  2477.     '
  2478.     NumPixels = X2SelectFrom - X1SelectFrom - 1
  2479.  
  2480.     ' Perform rotation.  The rotation is performed by reading one pixel at
  2481.     ' a time from the source and copying it to is new location in rotated
  2482.     ' either Left or Right 90 degrees.  The Point Method reads the Pixel
  2483.     ' and the Pset method is used to write the pixel.  Both the Icons
  2484.     ' Mask and Image must be rotated.
  2485.     '
  2486.     For Y = 0 To NumPixels
  2487.         For X = 0 To NumPixels
  2488.             If Index = MID_ROTATE_RIGHT Then
  2489.                 '
  2490.                 ' Rotate Right
  2491.                 '
  2492.                 Pic_Image.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + X), Pic_TempImage.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2493.                 Pic_Mask.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + X), Pic_TempMask.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2494.             Else
  2495.                 ' Rotate Left
  2496.                 '
  2497.                 Pic_Image.PSet (X1SelectFrom + Y, Y2SelectFrom - X - 1), Pic_TempImage.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2498.                 Pic_Mask.PSet (X1SelectFrom + Y, Y2SelectFrom - X - 1), Pic_TempMask.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2499.             End If
  2500.         Next X
  2501.     Next Y
  2502.  
  2503.     ' Replace Icons Mask and Image with new Mask and Images.
  2504.     '
  2505.     Update_Icon Pic_Icons(CurrentIcon)
  2506.     
  2507.     Prepare_For_Possible_Move
  2508.  
  2509.     ' Redisplay selected region to show rotation.
  2510.     '
  2511.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  2512.  
  2513.     ' Restore Cursor
  2514.     '
  2515.     Screen.MousePointer = DEFAULT
  2516.  
  2517. End Sub
  2518.  
  2519. ' In response to a Color.Save colors to INI file menu operatioin, this
  2520. ' routine is called to write the color values to IconWrks.INI.
  2521. ' WritePrivateProfileString() will create the INI file if it does not
  2522. ' exist, and will create the KeyName if it does not exist in the INI FILE.
  2523. ' The Color values are packed into a single string, one row of colors at
  2524. ' a time, and then written to the INI file.  The colors are formated
  2525. ' into 8-byte fields separated by one space.  After this routine,
  2526. ' IconWrks.INI will contain 3 key entries of:
  2527. '
  2528. '   Colors Row1=16777215 14737632 ...
  2529. '   Colors Row2=12632256 04210752 ...
  2530. '   Colors Row3=08421504 00000000 ...
  2531. '
  2532. Private Sub Save_Colors_To_INI_File()
  2533.     
  2534.     For i = 0 To 2
  2535.         ColorString = ""
  2536.         For C = 0 To 15
  2537.             ColorString = ColorString + Format$(Colors(i * 16 + C), "00000000 ")
  2538.         Next C
  2539.         X = WritePrivateProfileString(APP_NAME, KEY_COLOR + Format$(i + 1), ColorString, INI_FILENAME)
  2540.     Next i
  2541.  
  2542. End Sub
  2543.  
  2544. ' In Response to a File.Save or File.Save As menu operation, this routine
  2545. ' is called to either immediately save the Icon or invoke the SaveFileDlg
  2546. ' to get a Filename to save the Icon to.  A File.Save As operation always
  2547. ' invokes the Dialog, but a File.Save will only invoke the Dialog if the
  2548. ' current icon does not yet have a name, denoted by a name of UNTITLED.
  2549. '
  2550. Private Sub Save_Icon(Index)
  2551.     On Error Resume Next
  2552.     Dim LongName As String
  2553.     Dim Title As String
  2554.     Dim CDPath As String
  2555.  
  2556.     If (Index = MID_SAVE_AS) Or (ICONINFO(CurrentIcon).FileName = UNTITLED) Then
  2557.         ' Set default filter.
  2558.         Editor.CMDialog1.Filter = "Icon Files (*.ico)|*.ico"
  2559.         ' Display Save As dialog.
  2560.         Editor.CMDialog1.FilterIndex = 1
  2561.         Editor.CMDialog1.DefaultExt = "ICO"
  2562.         If Right(ICONINFO(CurrentIcon).FullPath, 1) <> "\" Then
  2563.           Editor.CMDialog1.FileName = ICONINFO(CurrentIcon).FullPath & "\" & ICONINFO(CurrentIcon).FileName
  2564.         End If
  2565.         ' If file has not been saved yet, set common dialog's
  2566.         ' default file name to *.ico
  2567.         If ICONINFO(CurrentIcon).FileName = "[Untitled]" Then
  2568.           Editor.CMDialog1.FileName = "*.ico"
  2569.         End If
  2570.         
  2571.         Editor.CMDialog1.Action = 2
  2572.         ' Exit if user cancels the dialog.
  2573.         If Err = 32755 Then Exit Sub
  2574.         Title = Editor.CMDialog1.FileTitle
  2575.         LongName = Editor.CMDialog1.FileName
  2576.         ICONINFO(CurrentIcon).FullPath = Left(LongName, Len(LongName) - Len(Title))
  2577.         ICONINFO(CurrentIcon).FileName = Editor.CMDialog1.FileTitle
  2578.         ' Adjust for root directory.
  2579.         If Len(ICONINFO(CurrentIcon).FullPath) = 3 Then
  2580.             CDPath = ICONINFO(CurrentIcon).FullPath
  2581.         Else
  2582.             CDPath = Left(LongName, Len(LongName) - Len(Title) - 1)
  2583.         End If
  2584.         ' Change directories for the editor and the viewer.
  2585.         ChDir CDPath
  2586.         Viewer.Dir_DirectoryList.Path = CDPath
  2587.     End If
  2588.         Write_Icon_To_File (ICONINFO(CurrentIcon).FullPath), ICONINFO(CurrentIcon).FileName
  2589. End Sub
  2590.  
  2591. ' When the Editor is terminated, this routine is called to save all
  2592. ' configurable items of the Editor to the IconWrks.INI file.  Size
  2593. ' and Location of the Editor are not saved.
  2594. '
  2595. ' WritePrivateProfileString() will create the INI file and/or any
  2596. ' KeyName that does not exist.
  2597. '
  2598. Private Sub Save_Settings_To_INI_File()
  2599.   
  2600.     R = WritePrivateProfileString(APP_NAME, KEY_GRID, Format$(Abs(Menu_ViewSelection(MID_GRID).Checked)), INI_FILENAME)
  2601.     R = WritePrivateProfileString(APP_NAME, KEY_LINE_GRID, Format$(Abs(Menu_ViewSelection(MID_LINE_GRID).Checked)), INI_FILENAME)
  2602.     R = WritePrivateProfileString(APP_NAME, KEY_DOTTED_GRID, Format$(Abs(Menu_ViewSelection(MID_DOTTED_GRID).Checked)), INI_FILENAME)
  2603.     R = WritePrivateProfileString(APP_NAME, KEY_STATUS_BAR, Format$(Abs(Menu_ViewSelection(MID_STATUS_BAR).Checked)), INI_FILENAME)
  2604.     R = WritePrivateProfileString(APP_NAME, KEY_TOOL_PALETTE, Format$(Abs(Menu_ViewSelection(MID_TOOL_PALETTE).Checked)), INI_FILENAME)
  2605.     R = WritePrivateProfileString(APP_NAME, KEY_COLOR_PALETTE, Format$(Abs(Menu_ViewSelection(MID_COLOR_PALETTE).Checked)), INI_FILENAME)
  2606.     R = WritePrivateProfileString(APP_NAME, KEY_ZOOM_SCROLLBAR, Format$(Abs(Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked)), INI_FILENAME)
  2607.     R = WritePrivateProfileString(APP_NAME, KEY_FOCUS, Format$(Abs(Menu_ViewSelection(MID_FOCUS).Checked)), INI_FILENAME)
  2608.     R = WritePrivateProfileString(APP_NAME, KEY_BORDER, Format$(Abs(Menu_ViewSelection(MID_BORDER).Checked)), INI_FILENAME)
  2609.     R = WritePrivateProfileString(APP_NAME, KEY_POPUP, Format$(Abs(Menu_ViewSelection(MID_POPUP_MENU).Checked)), INI_FILENAME)
  2610.     R = WritePrivateProfileString(APP_NAME, KEY_DEFAULT, Format$(Abs(Menu_ColorSelection(MID_DEFAULT_COLORS).Checked)), INI_FILENAME)
  2611.     R = WritePrivateProfileString(APP_NAME, KEY_SOLID, Format$(Abs(Menu_ColorSelection(MID_SOLID_COLORS).Checked)), INI_FILENAME)
  2612.     R = WritePrivateProfileString(APP_NAME, KEY_INI, Format$(Abs(Menu_ColorSelection(MID_INI_COLORS).Checked)), INI_FILENAME)
  2613.  
  2614. End Sub
  2615.  
  2616. ' Scrolling the Zoom scrollbar Zooms in or Zooms out on the
  2617. ' selected Icon, and maintains it centered within the available
  2618. ' editing space.
  2619. '
  2620. Private Sub Scrl_Zoom_Change()
  2621.     
  2622.     ' Check if new value is multiple of 32 pixels.  Magnified Icon must
  2623.     ' always be increased or decreased my muliples of 32 pixels so the
  2624.     ' Win API routine StretchBlt() can be used to magnify the Icon, and
  2625.     ' the result will be an exact enlargement of the original.
  2626.     '
  2627.     If (Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width Then
  2628.         '
  2629.         ' Scrollbar value is not a multiple of 32, so adjust it so it is.
  2630.         '
  2631.         Scrl_Zoom.Value = Scrl_Zoom.Value - ((Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width)
  2632.     Else
  2633.         ' Scrollbar value is a multiple of 32 pixels.
  2634.         '
  2635.         ' Hide Edit area while resizing and repainting.  It prevents a
  2636.         ' rather annoying visual affect.
  2637.         '
  2638.         Pic_Edit.Visible = False
  2639.  
  2640.         ' Calculate the new size and position values for the Editing area
  2641.         ' and then reposition and resize both the Editing area and the
  2642.         ' temporary Editing area which is used when magnifying the Icon.
  2643.         '
  2644.         MaxLeft = Scrl_Zoom.Left - (Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width)
  2645.         NewLeft = MaxLeft + (ScaleWidth + Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width - MaxLeft - Scrl_Zoom.Value) \ 2
  2646.         NewTop = (ScaleHeight + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height - Scrl_Zoom.Value) \ 2
  2647.         Pic_Edit.Move NewLeft, NewTop, Scrl_Zoom.Value, Scrl_Zoom.Value
  2648.         Pic_EditTemp.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  2649.  
  2650.         ' To allow a selection to be maintained if the Zoom scrollbar is scrolled
  2651.         ' while a selection is in progress, the current selection must be scaled
  2652.         ' down to the scale of the actual Icon, the new PixelSize for the Editing
  2653.         ' area must be calculated, and then the selection is Scaled back to the
  2654.         ' new scale of the Editing area.
  2655.         '
  2656.         If Selecting Then Scale_Region True, X1Region, Y1Region, X2Region, Y2Region, False
  2657.         PixelSize = Pic_Edit.ScaleWidth \ 32
  2658.         If Selecting Then Scale_Region False, X1Region, Y1Region, X2Region, Y2Region, False
  2659.  
  2660.         ' Recreate grid if selected and redisplay the Editing area.
  2661.         '
  2662.         If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  2663.         Pic_Edit.Visible = True
  2664.  
  2665.         ' Set enable state of Zoom in/out View menu items based on new value
  2666.         ' of the Zoom Scrollbar.
  2667.         '
  2668.         Menu_ViewSelection(MID_ZOOM_IN).Enabled = Scrl_Zoom.Value < Scrl_Zoom.Max
  2669.         Menu_ViewSelection(MID_ZOOM_OUT).Enabled = Scrl_Zoom.Value > Scrl_Zoom.Min
  2670.     End If
  2671.  
  2672. End Sub
  2673.  
  2674. ' In response to Double Clicking the Select tool, or an Edit.Select All
  2675. ' menu operation, this routine is called to perform a selection on the
  2676. ' entire Icon, which is the same as if the Entire icon was selected using
  2677. ' the mouse.
  2678. '
  2679. Private Sub Select_Entire_Icon()
  2680.     
  2681.     ' Make the select to the selected tool.  This is neccessary since
  2682.     ' this routine could have been called due to a menu selection, and
  2683.     ' the current tool may not be the Select Tool.
  2684.     '
  2685.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  2686.  
  2687.     ' Make all preparations for a selection just as if it was done
  2688.     ' using the mouse.
  2689.     '
  2690.     Prepare_For_Possible_Move
  2691.     Selecting = True
  2692.     
  2693.     Opaque = True
  2694.     Scale_Region False, 0, 0, 32, 32, False
  2695.     Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  2696.     Draw_Selection_Rectangle
  2697.  
  2698. End Sub
  2699.  
  2700. ' There are two type of grids to choose from when the Grid selection
  2701. ' is active. Line and Dotted grid.  This routine is called in response
  2702. ' to a View.Line Grid or View.Dotted Grid menu operation, to set and
  2703. ' display the selected grid type.  The actual Grid is created in the
  2704. ' Create_Grid procedure.
  2705. '
  2706. Private Sub Select_Grid_Type(Index)
  2707.     
  2708.     ' Check if selected Grid is already the currently selected grid type,
  2709.     ' since there is no need to redisplay it.
  2710.     '
  2711.     If Not Menu_ViewSelection(Index).Checked Then
  2712.         '
  2713.         ' Toggle Checks on Grid type menu items.
  2714.         '
  2715.         Menu_ViewSelection(MID_LINE_GRID).Checked = Not Menu_ViewSelection(MID_LINE_GRID).Checked
  2716.         Menu_ViewSelection(MID_DOTTED_GRID).Checked = Not Menu_ViewSelection(MID_DOTTED_GRID).Checked
  2717.  
  2718.         ' Create the new Grid and redisplay Icon with new Grid.
  2719.         '
  2720.         Create_Grid
  2721.         Magnify_Icon 0, 0, 31, 31
  2722.     End If
  2723.  
  2724. End Sub
  2725.  
  2726. Private Sub Select_Tool_MouseUp(X1, Y1, X2, Y2)
  2727.             
  2728.     ' Erase old Selection rectangle
  2729.     '
  2730.     Draw_Selection_Rectangle
  2731.  
  2732.     ' Adjust selection rectangle so it is completely within the
  2733.     ' editing area.
  2734.     '
  2735.     If X1Region > X2Region Then Swap_Values X1Region, X2Region
  2736.     If Y1Region > Y2Region Then Swap_Values Y1Region, Y2Region
  2737.     If X1Region < 0 Then X1Region = 0
  2738.     If Y1Region < 0 Then Y1Region = 0
  2739.     MaxSize = PixelSize * 32
  2740.     If X2Region > MaxSize Then X2Region = MaxSize
  2741.     If Y2Region > MaxSize Then Y2Region = MaxSize
  2742.  
  2743.     If MovingSelection Then
  2744.         '
  2745.         ' The selection is being moved, so all that needs to be done is
  2746.         ' to update the values containing the last location of the
  2747.         ' selection, which are used when the selection is moved.
  2748.         '
  2749.         X1 = LastX1
  2750.         Y1 = LastY1
  2751.         X2 = LastX2
  2752.         Y2 = LastY2
  2753.  
  2754.     ElseIf (X1Region <> X2Region) And (Y1Region <> Y2Region) Then
  2755.         '
  2756.         ' A new selection has been made
  2757.         '
  2758.         Prepare_For_Possible_Move
  2759.         Selecting = True
  2760.         Opaque = True
  2761.  
  2762.         ' Determine if selection can be moved.  The selection cannot be moved
  2763.         ' if it consists of the entire icon.
  2764.         '
  2765.        
  2766.  
  2767.         Draw_Selection_Rectangle
  2768.         Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  2769.     End If
  2770.     Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  2771.  
  2772. End Sub
  2773.  
  2774. ' A move event using the Select tool, can do one of three things,
  2775. ' size the selection rectangle to make the selection, move the
  2776. ' current selection, or copy the current selection to another
  2777. ' location.  This routine either draws the selection rectangle
  2778. ' as the selection is being made or moves/copies the current
  2779. ' selection.
  2780. '
  2781. Private Sub Select_Tool_Move(Shift As Integer, X As Single, Y As Single)
  2782.  
  2783.     ' Erase old selection rectangle
  2784.     '
  2785.     Draw_Selection_Rectangle
  2786.  
  2787.     If MovingSelection Then
  2788.         '
  2789.         ' Calculate new location of Selection rectangle.
  2790.         '
  2791.         XLastMove = XMoveSelection
  2792.         YLastMove = YMoveSelection
  2793.         Adjust_X_and_Y X, Y, XMoveSelection, YMoveSelection, TO_EDGE
  2794.         X1Region = X1Region + (XMoveSelection - XLastMove)
  2795.         X2Region = X2Region + (XMoveSelection - XLastMove)
  2796.         Y1Region = Y1Region + (YMoveSelection - YLastMove)
  2797.         Y2Region = Y2Region + (YMoveSelection - YLastMove)
  2798.  
  2799.         ' Prevent Selection from being moved of the left or right
  2800.         ' of the editing area
  2801.         '
  2802.         If (X1Region < 0) Or (X2Region > (32 * PixelSize)) Then
  2803.             X1Region = X1Region - (XMoveSelection - XLastMove)
  2804.             X2Region = X2Region - (XMoveSelection - XLastMove)
  2805.         End If
  2806.         
  2807.         ' Prevent Selection from being moved of the top or bottom
  2808.         ' of the editing area
  2809.         '
  2810.         If (Y1Region < 0) Or Y2Region > (32 * PixelSize) Then
  2811.             Y1Region = Y1Region - (YMoveSelection - YLastMove)
  2812.             Y2Region = Y2Region - (YMoveSelection - YLastMove)
  2813.         End If
  2814.     Else
  2815.         ' A selection is being made, so adjust the mouse coordinates
  2816.         ' to the Edge of the pixels so the rectangle is completely
  2817.         ' around the selction.
  2818.         '
  2819.         Adjust_X_and_Y X, Y, X2Region, Y2Region, TO_EDGE
  2820.  
  2821.         ' Make the Selection perfectly square if the Shift key is down
  2822.         '
  2823.         If Shift And SHIFT_MASK Then Make_Region_Square
  2824.     End If
  2825.  
  2826.     ' Draw the new selection recangle
  2827.     '
  2828.     Draw_Selection_Rectangle
  2829.  
  2830. End Sub
  2831.  
  2832. ' When the MousePointer is within the Editing area, the MousePointer
  2833. ' is changed depending on the Tool being used.  This routine is called
  2834. ' from the MouseMove event for the Editing area (Pic_Edit) to change
  2835. ' the MousePointer.
  2836. '
  2837. Private Sub Set_MousePointer(X As Single, Y As Single)
  2838.     
  2839.     If Selecting And Moveable And (X >= X1Region) And (X <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region) Then
  2840.         '
  2841.         ' A selection is in progress and the selection is moveable,
  2842.         ' and the MousePointer is within the the selection, so the
  2843.         ' MousePointer is changed to a SIZE pointer to indacte
  2844.         ' that the Selection can be moved.
  2845.         '
  2846.         Pic_Edit.MousePointer = SIZE
  2847.     ElseIf (CurrentTool = TID_PAINT) Or (CurrentTool = TID_FILL) Then
  2848.         Pic_Edit.MousePointer = UP_ARROW
  2849.     Else
  2850.         Pic_Edit.MousePointer = CROSSHAIR
  2851.     End If
  2852.  
  2853. End Sub
  2854.  
  2855. ' Since some of the tools can only use Solid colors and not Dithered
  2856. ' colors, it is useful to have the option of displayin only the solid
  2857. ' colors within the ColorPalette.  This routine changes the Color
  2858. ' array to contain only Solid color values then redisplays the
  2859. ' ColorPalette.  There are still 3 rows of colors, but each color
  2860. ' cell in the same column are set to the same solid color.
  2861. '
  2862. Private Sub Show_Solid_Colors_Only()
  2863.     
  2864.     ' Set Color array to all solid colors returned from QBColors()
  2865.     '
  2866.     For i = 0 To 15
  2867.         Colors(i) = QBColor(i)
  2868.         Colors(i + 16) = QBColor(i)
  2869.         Colors(i + 32) = QBColor(i)
  2870.     Next
  2871.  
  2872.     ' Redisplay ColorPalettes.
  2873.     '
  2874.     Display_Color_Palette Pic_ColorPalette
  2875.     If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  2876.  
  2877. End Sub
  2878.  
  2879. ' This routine is called in response to an Edit.Undo menu operation.
  2880. ' The Icon displayed in the Undo Icon within the StatusArea is
  2881. ' Copied to the Selected Icon.
  2882. '
  2883. Private Sub UnDo_Edits()
  2884.     
  2885.     ' Terminate any Select or Move opteration
  2886.     '
  2887.     Selecting = False
  2888.     MovingSelection = False
  2889.  
  2890.     ' Get Image and Mask of Icon displayed in Undo Icon in StatusArea
  2891.     '
  2892.     Extract_Image_And_Mask Pic_Undo
  2893.  
  2894.     ' Copy Undo Icons Mask and Image to selected icon
  2895.     '
  2896.     Update_Icon Pic_Icons(CurrentIcon)
  2897.  
  2898.     ' Redisplay entire icon
  2899.     '
  2900.     Magnify_Icon 0, 0, 31, 31
  2901.  
  2902. End Sub
  2903.  
  2904. ' When using either the Circle or Filled Circle tool, this routine is called
  2905. ' to verify that the resulting circle from the current Mouse coordinates is
  2906. ' a valid circle, since in some cases the result would be a vertical or
  2907. ' horizontal line which would generate and "Division by Zero" if not checked
  2908. ' for.  If the Circle is valid, this routine calculates and sets the Global
  2909. ' values of XCenter, YCenter, and Raduis for new Circle.
  2910. '
  2911. Private Function Valid_Circle(X1, Y1, X2, Y2)
  2912.           
  2913.     Xleg = Abs(X2 - X1)
  2914.     If Xleg <> 0 Then
  2915.         Yleg = Abs(Y2 - Y1)
  2916.         Aspect = Abs(Yleg / Xleg)
  2917.         If Xleg > Yleg Then Radius = Xleg / 2 Else Radius = Yleg / 2
  2918.         XCenter = X1 + (X2 - X1) / 2
  2919.         YCenter = Y1 + (Y2 - Y1) / 2
  2920.     End If
  2921.  
  2922.     ' Return value of XLeg at Function value, since if XLeg is non-zero,
  2923.     ' (True) it is a valid circle, and if XLeg is zero (False) it is
  2924.     ' an Invalid circle.
  2925.     '
  2926.     Valid_Circle = Xleg
  2927.  
  2928. End Function
  2929.  
  2930.